Import object.

@param Array getParameters.
@param Array getOptions.
@param Array postParameters.
@param Array postOptions.
@param string Import type.

@return DOMElement DOMElement containing OO document.
16128
protected function importOODocument( $getParams, $getOptions, $postParams, $postOptions, $importType = 'import' )
    {
        $nodeID = $postParams['nodeID'];
        $data = $postParams['data'];
        // Alex 2008/04/22 - Added format argument: 'odt' (default), 'doc'
        $format = $postOptions['format'];
        $languageCode = $postOptions['languageCode'];
        $base64Encoded = $postOptions['base64Encoded'];

        $node = eZContentObjectTreeNode::fetch( $nodeID, $languageCode );

        if ( !$node )
        {
            throw new Exception( 'Could not fetch node: ' . $nodeID );
        }

        // Decode data.
        if ( $base64Encoded )
        {
            // Alex 2008/04/16 - Added str_replace()
            $data = base64_decode( str_replace( ' ', '+', $data ) );
        }

        // Store data to temporary file.
        // Alex 2008/04/22 - Added format argument: 'odt' (default), 'doc'
        $filename = substr( md5( mt_rand() ), 0, 8 ) . ".{$format}";
        $tmpFilePath = eZSys::cacheDirectory() . '/ezodf/' . substr( md5( mt_rand() ), 0, 8 );
        $tmpFilename = $tmpFilePath . '/' . $filename;
        if ( !eZFile::create( $filename, $tmpFilePath, $data ) )
        {
            throw new Exception( 'Could not create file: ' . $tmpFilename );
        }

        $import = new eZOOImport();
        $result = $import->import( $tmpFilename, $nodeID, $filename, $importType );
        eZDir::recursiveDelete( $tmpFilePath );
        if ( !$result )
        {
            throw new Exception( 'OO import failed: ' . $import->getErrorNumber() . ' - ' . $import->getErrorMessage() );
        }

        $domDocument = new DOMDocument( '1.0', 'utf-8' );
        $importElement = $domDocument->createElement( 'OOImport' );

        // Add node info about imported document.
        $importElement->appendChild( $this->createTreeNodeDOMElement( $domDocument, $result['MainNode'] ) );

        return $importElement;
    }
858140
public function importFromArray(array $options)
    {
        foreach ($options as $key => $value) {
            switch (true) {
                case $key === 'args':
                    $this->args = $value;
                    break;
                case is_integer($key):
                    $this->args[] = $value;
                    break;
                default:
                    $this->options[$key] = $value;
                    break;
            }
        }
    }
926687
function importCustomSelectorsFromObject(object) {
	const customSelectors = Object.assign(
		{},
		Object(object).customSelectors || Object(object)['custom-selectors']
	);

	for (const key in customSelectors) {
		customSelectors[key] = getSelectorsAstFromSelectorsString(customSelectors[key]);
	}

	return customSelectors;
}
1275907
private void addClassProperties() {

    List<VariableElement> fields = processingContext.allFields(element);

    for (VariableElement field : fields) {
      PropertyType type = processingContext.getPropertyType(field);
      if (type != null) {
        type.addImports(importTypes);
        properties.add(new PropertyMeta(field.getSimpleName().toString(), type));
      }
    }
  }
994154
public function import($calendarId, Google_Event $postBody, $optParams = array()) {
      $params = array('calendarId' => $calendarId, 'postBody' => $postBody);
      $params = array_merge($params, $optParams);
      $data = $this->__call('import', array($params));
      if ($this->useObjects()) {
        return new Google_Event($data);
      } else {
        return $data;
      }
    }
828429
public function create($type)
    {
        $typeOptions    = $this->getOption(self::OPTION_MAPPERS);
        $typeOption     = isset($typeOptions[$type]) ? $typeOptions[$type] : $this->throwException();
        $importerString = isset($typeOption[self::OPTION_MAPPERS_IMPORTER]) ? $typeOption[self::OPTION_MAPPERS_IMPORTER] : $this->throwException();
        $importer       = $this->buildService($importerString, ImportServiceInterface::class);

        if (isset($typeOption[self::OPTION_MAPPERS_MAPPER])) {
            $mapperString = $typeOption[self::OPTION_MAPPERS_MAPPER];
            $mapper       = $this->buildService($mapperString);
        } else {
            $mapper = $this->getDefaultMapper();
        }

        $this->propagate($mapper);
        $importer->setMapper($mapper);

        return $importer;
    }
50262
static public function importAttributes(DOMElement $from, DOMElement $into)
    {
        for ($i = 0; $i < $from->attributes->length; $i++) {
            $attr = $from->attributes->item($i);

            if ($attr->localName !== 'schemaLocation') {

                if (empty($attr->namespaceURI) === false) {
                    $into->setAttributeNS($attr->namespaceURI, $attr->prefix . ':' . $attr->localName, $attr->value);
                } else {
                    $into->setAttribute($attr->localName, $attr->value);
                }
            }
        }
    }
1151990
public function get(& $transport, $options = array (), $element = null) {
        $object = null;
        $element = parent :: get($transport, $options, $element);
        if (isset ($element['class']) && isset ($element['object'])) {
            $vClass = $element['class'];
            if (!empty ($element['package'])) {
                $pkgPrefix = $element['package'];
                $pkgKeys = array_keys($transport->xpdo->packages);
                if ($pkgFound = in_array($pkgPrefix, $pkgKeys)) {
                    $pkgPrefix = '';
                }
                elseif ($pos = strpos($pkgPrefix, '.')) {
                    $prefixParts = explode('.', $pkgPrefix);
                    $prefix = '';
                    foreach ($prefixParts as $prefixPart) {
                        $prefix .= $prefixPart;
                        $pkgPrefix = substr($pkgPrefix, $pos +1);
                        if ($pkgFound = in_array($prefix, $pkgKeys))
                            break;
                        $prefix .= '.';
                        $pos = strpos($pkgPrefix, '.');
                    }
                    if (!$pkgFound)
                        $pkgPrefix = $element['package'];
                }
                $vClass = (!empty ($pkgPrefix) ? $pkgPrefix . '.' : '') . $vClass;
            }
            $object = $transport->xpdo->newObject($vClass);
            if (is_object($object) && $object instanceof xPDOObject) {
                $options = array_merge($options, $element);
                $setKeys = false;
                if (isset ($options[xPDOTransport::PRESERVE_KEYS])) {
                    $setKeys = (boolean) $options[xPDOTransport::PRESERVE_KEYS];
                }
                $object->fromJSON($element['object'], '', $setKeys, true);
            }
        }
        return $object;
    }
1313930
@Override
    public List<URI> importServices(InputStream servicesContentStream,
                                    String mediaType) throws SalException {

        boolean isNativeFormat = MediaType.NATIVE_MEDIATYPE_SYNTAX_MAP.containsKey(mediaType);
        // Throw error if Format Unsupported
        if (!isNativeFormat && !this.serviceTransformationEngine.canTransform(mediaType)) {
            log.error("The media type {} is not natively supported and has no suitable transformer.", mediaType);
            throw new ServiceException("Unable to import service. Format unsupported.");
        }

        // Obtain the file extension to use
        String fileExtension = findFileExtensionToUse(mediaType, isNativeFormat);

        List<Service> services = null;
        List<URI> importedServices = new ArrayList<URI>();
        URI sourceDocUri = null;
        InputStream localStream = null;
        try {
            // 1st Store the document
            sourceDocUri = this.docManager.createDocument(servicesContentStream, fileExtension, mediaType);
            if (sourceDocUri == null) {
                throw new ServiceException("Unable to save service document. Operation aborted.");
            }

            // 2nd Parse and Transform the document
            // The original stream may be a one-of stream so save it first and read locally
            localStream = this.docManager.getDocument(sourceDocUri);
            services = getServicesFromStream(mediaType, isNativeFormat, localStream);

            // 3rd - Store the resulting MSM services. There may be more than one
            URI serviceUri = null;
            if (services != null && !services.isEmpty()) {
                log.info("Importing {} services", services.size());
                for (Service service : services) {
                    // The service is being imported -> update the source
                    service.setSource(sourceDocUri);
                    serviceUri = this.serviceManager.addService(service);
                    if (serviceUri != null) {
                        importedServices.add(serviceUri);
                    }
                }
            }

            // 4th Log it was all done correctly
            // TODO: log to the system and notify observers
            log.info("Source document imported: {}", sourceDocUri.toASCIIString());

        } finally {
            // Rollback if something went wrong
            if ((services == null || (services != null && services.size() != importedServices.size()))
                    && sourceDocUri != null) {
                this.docManager.deleteDocument(sourceDocUri);
                for (URI svcUri : importedServices) {
                    this.serviceManager.deleteService(svcUri);
                }
                log.warn("There were problems importing the service. Changes undone.");
            }

            if (localStream != null)
                try {
                    localStream.close();
                } catch (IOException e) {
                    log.error("Error closing the service content stream", e);
                }
        }

        return importedServices;
    }
462242
function IntegrationType(required, optional = []) {
    //convert parameter string values to object
    this.required = required.map(transformProps);
    this.optional = optional.map(transformProps);
}
1257191
function importTypes(names: Array<string>, module: string) {
  const importDeclaration = t.importDeclaration(
    names.map(name =>
      t.importSpecifier(t.identifier(name), t.identifier(name)),
    ),
    t.stringLiteral(module),
  );
  importDeclaration.importKind = 'type';
  return importDeclaration;
}
962699
public function importAction()
    {

        $form = $this->formFactory->create(new ImportUserType(true));
        $form->handleRequest($this->request);
        $mode = $form->get('mode')->getData();

        if ($mode === 'update') {
            $form = $this->formFactory->create(new ImportUserType(true, 1));
            $form->handleRequest($this->request);
        }

        if ($form->isValid()) {
            $file = $form->get('file')->getData();
            $sendMail = $form->get('sendMail')->getData();
            $data = file_get_contents($file);
            $data = $this->container->get('claroline.utilities.misc')->formatCsvOutput($data);
            $lines = str_getcsv($data, PHP_EOL);
            $users = array();
            $toUpdate = array();
            $sessionFlashBag = $this->session->getFlashBag();

            foreach ($lines as $line) {

                if ($mode === 'update') {
                    $datas = str_getcsv($line, ';');
                    $username = $datas[2];
                    $email = $datas[4];
                    $existingUser = $this->userManager->getUserByUsernameOrMail(
                        $username,
                        $email
                    );

                    if (is_null($existingUser)) {
                        $users[] = $datas;
                    } else {
                        $toUpdate[] = $datas;
                    }
                } else {
                    $users[] = str_getcsv($line, ';');
                }
            }

            $roleUser = $this->roleManager->getRoleByName('ROLE_USER');
            $max = $roleUser->getMaxUsers();
            $total = $this->userManager->countUsersByRoleIncludingGroup($roleUser);

            if ($total + count($users) > $max) {

                return array('form' => $form->createView(), 'error' => 'role_user unavailable');
            }

            $additionalRoles = $form->get('roles')->getData();

            foreach ($additionalRoles as $additionalRole) {
                $max = $additionalRole->getMaxUsers();
                $total = $this->userManager->countUsersByRoleIncludingGroup($additionalRole);

                if ($total + count($users) > $max) {

                    return array(
                        'form' => $form->createView(),
                        'error' => $additionalRole->getName() . ' unavailable'
                    );
                }
            }

            if (count($toUpdate) > 0) {
                $updatedNames = $this->userManager->updateImportedUsers(
                    $toUpdate,
                    $additionalRoles->toArray()
                );

                foreach ($updatedNames as $name) {
                    $msg =  '<' . $name . '> ';
                    $msg .= $this->translator->trans(
                        'has_been_updated',
                        array(),
                        'platform'
                    );
                    $sessionFlashBag->add('success', $msg);
                }
            }
            $createdNames = $this->userManager->importUsers(
                $users,
                $sendMail,
                null,
                $additionalRoles
            );

            foreach ($createdNames as $name) {
                $msg =  '<' . $name . '> ';
                $msg .= $this->translator->trans(
                    'has_been_created',
                    array(),
                    'platform'
                );
                $sessionFlashBag->add('success', $msg);
            }

            return new RedirectResponse($this->router->generate('claro_admin_users_index'));
        }

        return array('form' => $form->createView());
    }
1064718
function(action, channel, imports, sysImports, contentParts, next, invokeOverride) {
    var self = this,
    errStr,
    parsingError = false,
    schemePtr,
    mixedTypes = [ 'mixed', 'array', 'object' ]

    if (this.actions[action].invoke) {

      if (!channel.config) {
        channel.config = {};
      }

      if (!contentParts) {
        contentParts = {
          _files : []
        }
      }

      try {

        // apply channel config defaults into imports, if required
        // fields don't already exist
        var actionSchema = this.getAction(action),
          missingFields = (actionSchema.imports && actionSchema.imports.required && actionSchema.imports.required.length) ? actionSchema.imports.required : [];

        // apply config defaults
        var configDefaults = this.getActionConfigDefaults(action),
          configSchema = this.getActionConfig(action).properties,
          importSchema = this.getActionImports(action).properties;

        _.each(configDefaults, function(value, key) {
          if (!channel.config[key]) {
            channel.config[key] = value;
          }
        });

        // transpose from config to imports (no need to reference channel.config in pods)
        _.each(channel.config, function(value, key) {
          // convert to boolean if not already
          if (configSchema[key] && 'boolean' === configSchema[key].type) {
            channel.config[key] = helper.isTruthy(value) ? true : false;
          }

          if (!imports[key]) {
            imports[key] = channel.config[key];
          }
        });

        // derive import defaults
        var importDefaults = this.getActionImportDefaults(action);
        _.each(importDefaults, function(value, key) {
          if (!imports[key]) {
            imports[key] = value;
          }
        });

        for (var k in imports) {
          // trim empty import
          if (imports.hasOwnProperty(k) && '' === imports[k]) {
            delete imports[k];
            continue;
          }

          if (missingFields.length && missingFields.indexOf(k) > -1  ){
        	   missingFields.splice(missingFields.indexOf(k) ,1);
          }

        var mixed;
		    if(
          importSchema[k] && importSchema[k].type
          || configSchema[k] && configSchema[k].type
          ) {
			  	p_errStr = null;
			  	value = imports[k];

          if (importSchema[k]) {
            schemePtr = importSchema[k];
          } else if (configSchema[k]) {
            schemePtr = configSchema[k];
          }

          type = schemePtr.type.toLowerCase();

          //
          if ('number' === type) {
            pValue = helper.stringToFloat(value);
            if (0 !== pValue && !pValue) {
              p_errStr = k + ': String cannot be converted to Number';
            } else {
              imports[k] = pValue;
            }

          } else if ('integer' === type) {
            pValue = helper.stringToInt(value);
            if (0 !== pValue && !pValue) {
              p_errStr = k + ': String cannot be converted to Integer';
            } else {
              imports[k] = pValue;
            }

          } else if ('boolean' === type) {

            var pValue = helper.stringToBoolean(value);

            if (pValue == null) {
              p_errStr = k + ': String cannot be converted to Boolean';
            } else {
              imports[k] = pValue;
            }

          } else if (-1 !== mixedTypes.indexOf(type) ) {
            if ('object' === type && helper.isObject(value)) {
              imports[k] = value;

            } else if ('array' === type && helper.isArray(value)) {
              imports[k] = value;

            } else {
              pValue = helper.stringToJson(value);

              if (pValue) {
                imports[k] = pValue;

              } else if(!pValue){
                imports[k] = value;

              } else {
                p_errStr = k + ': String cannot be converted to '
                  + (('mixed' === type || 'object' === type) ? 'Object' : 'Array') ;
              }
            }
          }

        	if(p_errStr){
        		parsingError = true;
        		self.log(p_errStr, channel, 'error');
        		next.call(self, p_errStr);
        	}
			  }
      }

      if(missingFields.length){
        errStr = 'Missing Required Field(s):' + missingFields.join();
        self.log(errStr, channel, 'error');
        next.call(self, errStr)
      }

      if (!missingFields.length && !parsingError) {
        var invokeMethod = 'invoke' === this.getTriggerType() ? 'invoke' : 'trigger';

        // @deprecate -- when all trigger actions support 'trigger' method
        if (invokeOverride || !this.actions[action][invokeMethod]) {
          invokeMethod = 'invoke';
        }

        //
        this.actions[action][invokeMethod](imports, channel, sysImports, contentParts, function(err, exports) {
          if (err) {
            self.log(err, channel, 'error');
          }
          next.apply(self, arguments);
        });
      }
     } catch (e) {
       errStr = 'EXCEPT ' + e.toString();
       self.log(errStr, channel, 'error');
 	  	 next.call(self, errStr);
     }
    }
  }
461294
function(options) {
	var constantsData = options.constantsData;
	var location = options.location;
	var index = options.index;
	var name = options.name;

	var bufferInfo;
	var addData = false;

	// Search for a buffer's info
	array_registers.forEach(function(arrayRegister) {
		if(name === arrayRegister.data) {
			bufferInfo = {
				'size': arrayRegister.size,
			};
			var importTypeData = true;
			if(arrayRegister.type) {
				if(arrayRegister.type !== 'raw') {
					bufferInfo.type = arrayRegister.type;
					importTypeData = false;
				}
			}
			if(importTypeData) {
				bufferInfo.type = constantsData[location][index].type;
			}
			addData = true;
		}
	});

	if(addData) {
		constantsData[location][index].bufferInfo = bufferInfo;
	}
}
509157
private List<PostConstructInfo> processPostConstruct(TypeElement type) {
        List<PostConstructInfo> postConstructs = new ArrayList<>();

        ElementFilter.methodsIn(type.getEnclosedElements()).stream()
                .filter(method -> MoreElements.isAnnotationPresent(method, PostConstruct.class))
                .forEach(method -> {

                    // verify method
                    if (method.getModifiers().contains(Modifier.PRIVATE)) {
                        abortWithError(method, "@%s method must not be private", PostConstruct.class.getSimpleName());
                    }
                    if (method.getModifiers().contains(Modifier.STATIC)) {
                        abortWithError(method, "@%s method must not be static", PostConstruct.class.getSimpleName());
                    }
                    if (!method.getReturnType().equals(typeUtils.getNoType(TypeKind.VOID))) {
                        abortWithError(method, "@%s method must return void", PostConstruct.class.getSimpleName());
                    }
                    if (!method.getParameters().isEmpty()) {
                        abortWithError(method, "@%s method must not have parameters",
                                PostConstruct.class.getSimpleName());
                    }

                    postConstructs.add(new PostConstructInfo(method.getSimpleName().toString()));
                });

        if (postConstructs.size() > 1) {
            warning(type, "%d methods annotated with @%s found. Order is not guaranteed!", postConstructs.size(),
                    PostConstruct.class.getSimpleName());
        }
        return postConstructs;
    }
41854
public function import($modelName, $defaultValues = [], $updateMultipleModel = false, $queryConfigs = [])
	{
		$isSuccessful = true;

		$sheetData = $this->arrayFromExcel;
		$this->header = array_shift($sheetData);

		foreach ($sheetData as $record) {

			if ($updateMultipleModel) {

				$parentId = $this->getParentId($queryConfigs['parentModel'], $queryConfigs['parentKey'],
				$record, $modelName, $defaultValues);

				$childModel = new $queryConfigs['childModel'];
				foreach ($queryConfigs['childModelArray'] as $key=>$value) {
					if (!is_array($value)) {
						$childModel->$value = $this->getCellValue($value, $childModel, $record, $key, false);
					} else {
						$childModel->$value['attribute'] = $this->getCellValue($value, $childModel, $record, $key, false);
					}
				}

				$childModel->$queryConfigs['childForeignKey'] = $parentId;
				$childModel->save();
			} else {

				$isSuccessful = $this->createModel($modelName, $defaultValues, $record);
			}
		}
		return $isSuccessful;
	}
98065
function (model, pojo, options) {
  pojo = pojo || {};

  let props = model.serializeProperties || model.properties;

  props = props.filter(prop => (!model.propertyOptions[prop] || model.propertyOptions[prop].serialize !== false));

  props.forEach(key => {
    let obj;

    let o = model.propertyOptions[key];

    if (o && o.preSerialize) {
      obj = o.preSerialize(options);
    } else {
      obj = model[key];
    }

    if (obj instanceof Array) {
      let newArr = [];

      obj.forEach(item => {
        newArr.push(item instanceof Model ? item.serialize() : item);
      });

      pojo[key] = newArr;
    } else if (obj instanceof Model) {
      pojo[key] = obj.serialize(options);
    } else {
      pojo[key] = obj;
    }

    if (o && o.postSerialize) {
      o.postSerialize(options);
    }
  });

  if (model.postSerialize) {
    model.postSerialize(pojo, options);
  }

  return pojo;
}