Map from a Google document to a Search Document

@param Document $obj_source
@param GoogleDocument $obj_target
@return GoogleDocument
962717
public function toGoogle(Document $obj_source, GoogleDocument $obj_target)
    {
        $obj_target->setId($obj_source->getId());

        // Field data
        foreach($obj_source->getSchema()->getFields() as $str_name => $int_type) {
            $obj_value = $obj_target->addField()->setName($str_name)->mutableValue();
            if(Schema::FIELD_GEOPOINT === $int_type) {
                $obj_value->setType(ContentType::GEO);
                if(isset($obj_source->{$str_name}) && is_array($obj_source->{$str_name})) {
                    $arr_geo = $obj_source->{$str_name};
                    $obj_value->mutableGeo()->setLat($arr_geo[0])->setLng($arr_geo[1]);
                } else {
                    throw new \InvalidArgumentException('Geopoint data is required');
                }
            } else {
                if(isset(self::$arr_types[$int_type])) {
                    $obj_value->setType(self::$arr_types[$int_type]);
                } else {
                    throw new \InvalidArgumentException('Unknown type mapping to Google Document');
                }
                // @todo deal with specific field types requiring null / blanks / values
                if(isset($obj_source->{$str_name})) {
                    $mix_val = $obj_source->{$str_name};
                    if($mix_val instanceof \DateTime) {
                        $obj_value->setStringValue($mix_val->format('Y-m-d'));
                    } else {
                        $obj_value->setStringValue((string)$mix_val);
                    }
                } else {
                    $obj_value->setStringValue(null);
                }
            }
        }

        // Facets
        foreach($obj_source->getFacets() as $arr_facet) {
            $obj_facet = $obj_target->addFacet()->setName($arr_facet['name']);
            if(isset($arr_facet['atom'])) {
                $obj_facet->mutableValue()->setType(\storage_onestore_v3\FacetValue\ContentType::ATOM)->setStringValue($arr_facet['atom']);
            } elseif (isset($arr_facet['number'])) {
                $obj_facet->mutableValue()->setType(\storage_onestore_v3\FacetValue\ContentType::NUMBER)->setStringValue($arr_facet['number']);
            }
        }

        return $obj_target;
    }
184631
private function getArticleMap(string $sourceLanguage, string $targetLanguage): ArticleMap
    {
        if (!array_key_exists($key = $sourceLanguage . '->' . $targetLanguage, $this->articleMaps)) {
            return $this->articleMaps[$key] = new ArticleMap(
                $this->getPageMap($sourceLanguage, $targetLanguage),
                $this->logger
            );
        }

        return $this->articleMaps[$key];
    }
1195195
function createFromMap(mapObject, content, url) {
  url = url || '<source>';
  if ('string' == typeof mapObject) {
    try {
      mapObject = JSON.parse(mapObject);
    } catch (err) {
      mapObject = {
        version: 3,
        names: [],
        mappings: '',
        file: ''
      };
    }
  }
  if (emptySources(mapObject)) {
    mapObject.sources = [url];
    mapObject.sourcesContent = [content];
  }

  return SourceMapGenerator.fromSourceMap(new SourceMapConsumer(mapObject));
}
894528
private function getPageMap(string $sourceLanguage, string $targetLanguage): PageMap
    {
        if (!array_key_exists($key = $sourceLanguage . '->' . $targetLanguage, $this->pageMaps)) {
            return $this->pageMaps[$key] = new PageMap(
                $sourceLanguage,
                $targetLanguage,
                $this->database,
                $this->logger
            );
        }

        return $this->pageMaps[$key];
    }
276254
public static <E> List<E> listify(ObjectMapper mapper, Object source, Class<E> targetElementType) {
        return (List<E>) collectify(mapper, source, List.class, targetElementType);
    }
1328795
def updateObjectFromXML(xml_doc, obj, mapping):
    
    nsmap = None
    if isinstance(mapping, dict):
        # The special key @namespaces is used to pass
        # namespaces and prefix mappings for xpath selectors.
        # e.g. {'x': 'http://example.com/namespace'}
        if '@namespaces' in mapping:
            nsmap = mapping['@namespaces']
    else:
        raise TypeError('Tag-to-property map must be a dict.')
    # Iterate over the keys of the translation dictionary from event objects
    # to xml objects, so we can update the fields with the new information
    for k, v in mapping.items():
        if k.startswith('@'):
            continue
        selected_text = None
        if isinstance(v, basestring):
            selector = v
        elif isinstance(v, list):
            selector = '/'.join(v)
        else:
            raise TypeError(
                'Invalid tag-to-property mapping dict: '
                'values must be strings or lists, not %s.' % (type(v),)
            )
        try:
            selected_text = xml_doc.xpath(selector, namespaces=nsmap)
            if isinstance(selected_text, list):
                selected_text = selected_text[0]
            selected_text = selected_text.text
            setattr(obj, k, selected_text)
        except IndexError:
            # Assume the value is missing. It's also possible that the
            # given selector is valid but wrong, but the more common
            # case is that the element is missing. To be consistent with
            # the prior implementation, empty resultsets just mean empty
            # attributes.
            continue
    return obj
248871
function(target, source) {
    target = cloneJSON(target);

    for (var key in source) {
      if (source.hasOwnProperty(key)) {
        if (isObject(target[key]) && isObject(source[key])) {
          target[key] = merge(target[key], source[key]);
        } else {
          target[key] = source[key];
        }
      }
    }
    return target;
  }
202694
public static Object getTranslatedObject(Object value, Class<?> sourceClass, Class<?> targetClass)
    {
        if (sourceClass.isAssignableFrom(Date.class))
        {
            value = PropertyAccessorHelper.fromDate(targetClass, sourceClass, value);
        }
        else
        {
            value = PropertyAccessorHelper.fromSourceToTargetClass(targetClass, sourceClass, value);
        }
        return value;
    }
348107
function traverseObject(toSearchObj, searchForObj) {
    const allKeys = Object.keys(toSearchObj);
    const len = allKeys.length;

    for (let i = 0; i < len; i++) {
      const key = allKeys[i];
      const val = toSearchObj[key];

      if (searchForObj[key] && !results[key]) {
        results[key] = val;
      } else if (isObject(val)) {
        traverseObject(val, searchForObj);
      } else if (isArray(val)) {
        traverseArray(val, searchForObj);
      }
    }
  }
345809
protected function populateObject($sourceObject, $targetObject, array $targetObjectCtorArgs = array()) {
		if (is_object($targetObject)) {
			$resultObject = $targetObject;
		}
		else {
			$ref = new ReflectionClass($targetObject);
			$resultObject = $ref->newInstanceArgs($targetObjectCtorArgs);
		}

		$ref = new ReflectionClass($sourceObject);
		foreach ($ref->getProperties() as $property) {
			$name=$property->getName();
			$resultObject->$name = $sourceObject->$name;
		}

		return $resultObject;
	}
457777
function(oArgs) {
    var elTarget = oArgs.target;

    // Validate target row
    var elTargetRow = this.getTrEl(elTarget);
    if(elTargetRow) {
        var e = oArgs.event;
        var bSHIFT = e.shiftKey;
        var bCTRL = e.ctrlKey || ((navigator.userAgent.toLowerCase().indexOf("mac") != -1) && e.metaKey);

        var oTargetRecord = this.getRecord(elTargetRow);
        var nTargetRecordIndex = this._oRecordSet.getRecordIndex(oTargetRecord);

        var oAnchor = this._getSelectionAnchor();

        var i;

        // Both SHIFT and CTRL
        if(bSHIFT && bCTRL) {
            // Validate anchor
            if(oAnchor) {
                if(this.isSelected(oAnchor.record)) {
                    // Select all rows between anchor row and target row, including target row
                    if(oAnchor.recordIndex < nTargetRecordIndex) {
                        for(i=oAnchor.recordIndex+1; i<=nTargetRecordIndex; i++) {
                            if(!this.isSelected(i)) {
                                this.selectRow(i);
                            }
                        }
                    }
                    // Select all rows between target row and anchor row, including target row
                    else {
                        for(i=oAnchor.recordIndex-1; i>=nTargetRecordIndex; i--) {
                            if(!this.isSelected(i)) {
                                this.selectRow(i);
                            }
                        }
                    }
                }
                else {
                    // Unselect all rows between anchor row and target row
                    if(oAnchor.recordIndex < nTargetRecordIndex) {
                        for(i=oAnchor.recordIndex+1; i<=nTargetRecordIndex-1; i++) {
                            if(this.isSelected(i)) {
                                this.unselectRow(i);
                            }
                        }
                    }
                    // Unselect all rows between target row and anchor row
                    else {
                        for(i=nTargetRecordIndex+1; i<=oAnchor.recordIndex-1; i++) {
                            if(this.isSelected(i)) {
                                this.unselectRow(i);
                            }
                        }
                    }
                    // Select the target row
                    this.selectRow(oTargetRecord);
                }
            }
            // Invalid anchor
            else {
                // Set anchor
                this._oAnchorRecord = oTargetRecord;

                // Toggle selection of target
                if(this.isSelected(oTargetRecord)) {
                    this.unselectRow(oTargetRecord);
                }
                else {
                    this.selectRow(oTargetRecord);
                }
            }
        }
         // Only SHIFT
        else if(bSHIFT) {
            this.unselectAllRows();

            // Validate anchor
            if(oAnchor) {
                // Select all rows between anchor row and target row,
                // including the anchor row and target row
                if(oAnchor.recordIndex < nTargetRecordIndex) {
                    for(i=oAnchor.recordIndex; i<=nTargetRecordIndex; i++) {
                        this.selectRow(i);
                    }
                }
                // Select all rows between target row and anchor row,
                // including the target row and anchor row
                else {
                    for(i=oAnchor.recordIndex; i>=nTargetRecordIndex; i--) {
                        this.selectRow(i);
                    }
                }
            }
            // Invalid anchor
            else {
                // Set anchor
                this._oAnchorRecord = oTargetRecord;

                // Select target row only
                this.selectRow(oTargetRecord);
            }
        }
        // Only CTRL
        else if(bCTRL) {
            // Set anchor
            this._oAnchorRecord = oTargetRecord;

            // Toggle selection of target
            if(this.isSelected(oTargetRecord)) {
                this.unselectRow(oTargetRecord);
            }
            else {
                this.selectRow(oTargetRecord);
            }
        }
        // Neither SHIFT nor CTRL
        else {
            this._handleSingleSelectionByMouse(oArgs);
            return;
        }
    }
}
783187
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'document' in _dict:
            args['document'] = DocumentSentimentResults._from_dict(
                _dict.get('document'))
        if 'targets' in _dict:
            args['targets'] = [
                TargetedSentimentResults._from_dict(x)
                for x in (_dict.get('targets'))
            ]
        return cls(**args)
276983
private function mapExpressions(array $arr_fields, Document $obj_doc)
    {
        foreach($arr_fields as $obj_field) {
            $str_field_name = $obj_field->getName();
            $obj_value = $obj_field->getValue();
            if(ContentType::GEO === $obj_value->getType()) {
                $obj_geo = $obj_value->getGeo();
                $obj_doc->setExpression($str_field_name, [$obj_geo->getLat(), $obj_geo->getLng()]);
            } else {
                if(isset(self::$arr_types_rev[$obj_value->getType()])) {
                    $obj_doc->setExpression($str_field_name, $obj_value->getStringValue());
                } else {
                    throw new \InvalidArgumentException('Unknown type mapping from Expressions');
                }
            }
        }
    }
274655
function (obj) { 
        if (obj == null) { 
            obj = new OpenLayers.Layer.ArcGISCache(this.name, this.url, this.options);
        }
        return OpenLayers.Layer.XYZ.prototype.clone.apply(this, [obj]);
    }
377722
function shallowCopy (targetObj, srcObj) {
      each(srcObj, function (prop) {
        targetObj[prop] = srcObj[prop];
      });

      return targetObj;
    }
465359
static function RecurseXmlObjToArr($obj, &$arr)
	{
		$children = $obj->children();
		foreach ($children as $elementName => $node)
		{
			$nextIdx = count($arr);
			$arr[$nextIdx] = array();
			$arr[$nextIdx]['@name'] = strtolower((string)$elementName);
			$arr[$nextIdx]['@attributes'] = array();
			$attributes = $node->attributes();
			foreach ($attributes as $attributeName => $attributeValue)
			{
				$attribName = strtolower(trim((string)$attributeName));
				$attribVal = trim((string)$attributeValue);
				$arr[$nextIdx]['@attributes'][$attribName] = $attribVal;
			}
			$text = (string)$node;
			$text = trim($text);
			if (strlen($text) > 0)
			{
				$arr[$nextIdx]['@text'] = $text;
			}
			$arr[$nextIdx]['@children'] = array();
			VerySimpleXmlUtil::RecurseXmlObjToArr($node, $arr[$nextIdx]['@children']);
		}
		return;
	}
3234
function(source, target) {
        var linkedTarget = $(target);
        clearLinkedData(target);
        $.each(source, function(key, sourceValue) {
            if (isInternal(key)) {
                return;
            }
            var targetValue = null;
            if ($.isPlainObject(sourceValue)) {
                targetValue = target[key];
                setLinkedData(sourceValue, targetValue);
            } else if ($.isArray(sourceValue)) {
                targetValue = target[key];
                $.each(sourceValue, function(index, arrayValue) {
                    var targetArrayValue = targetValue[index];
                    setLinkedData(arrayValue, targetArrayValue);
                });
            } else {
                linkedTarget.setField(key, sourceValue);
            }
            return;
        });
    }