Saves field values to preferences.
427893
private void save() {
    Preferences pref = Preferences
        .userNodeForPackage(ConnectionDialog.class);

    pref.put("host", getHost());
    pref.put("user", getUser());

    boolean remember = getRememberPasswordCheckBox().isSelected();
    if (remember) {
      try {
        Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
        KeyGenerator keygen = KeyGenerator.getInstance("AES");
        SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
        random.setSeed(new byte[]{
          0x60, (byte) 0xFD, 0x28, 0x07, 0x35, 0x4A, 0x0D, 0x3B
        });
        byte[] iv = new byte[16];
        random.nextBytes(iv);
        IvParameterSpec spec = new IvParameterSpec(iv);
        keygen.init(128, random);
        cipher.init(Cipher.ENCRYPT_MODE, keygen.generateKey(), spec);
        byte[] clearText = getPassword().getBytes();
        byte[] cipherText = cipher.doFinal(clearText);
        pref.putByteArray("password", cipherText);
        pref.putBoolean("remember", true);
      } catch (Exception e) {
        logger.error("Could not encrypt password", e);
        pref.remove("password");
        pref.putBoolean("remember", false);
      }
    } else {
      pref.remove("password");
      pref.putBoolean("remember", false);
    }
  }
1340438
public function saveFields()
    {
        if (empty($this->fields)) {
            return;
        }

        $ids = [];

        // Retrieve all fields ids
        foreach ($this->fields as $field) {
            if (!$field) {
                continue;
            }

            // Build contents
            $ctn = (array) $field->getModel()->getContents();
            $hasId = (boolean) $field->getModel()->getHasId();

            // Check ID
            if ($hasId && (!isset($ctn['id']) || empty($ctn['id']))) {
                continue;
            }

            $ids[] = $ctn['id'];
        }

        $this->saveRequest($ids);
        $this->saveFiles($ids);
    }
1298318
public function saveModelInternal()
    {
        // Purge the field values from the attributes
        $this->model->attributes = array_diff_key($this->model->attributes, $this->fieldValues);
    }
346911
protected synchronized void save() {
        try {
            JSONArray jsonArray = new JSONArray();
            for (Job job : mQueue) {
                if (!(job instanceof InternalJob)) continue;
                InternalJob internalJob = (InternalJob) job;
                jsonArray.put(internalJob.toJSON());
            }

            SharedPreferences prefs = WonderPushConfiguration.getSharedPreferences();
            SharedPreferences.Editor editor = prefs.edit();
            editor.putString(getPrefName(), jsonArray.toString());
            editor.apply();
        } catch (JSONException e) {
            Log.e(TAG, "Could not save job queue", e);
        } catch (Exception e) {
            Log.e(TAG, "Could not save job queue", e);
        }
    }
1001043
public void saveField(DateTimeFieldType fieldType, int value) {
        obtainSaveField().init(fieldType.getField(iChrono), value);
    }
178011
public void saveSettings(Map<String, String> settings) throws Exception {

        for (Map.Entry<String, String> entry : settings.entrySet()) {
            String key = entry.getKey();
            String value = entry.getValue();
            saveSetting(key, value);
        }
        m_currentPreferences.save(m_cms);
        CmsWorkplace.updateUserPreferences(m_cms, m_request);
    }
936845
private void storeField(Field field, StructImpl fieldsMap) {
	String fieldName = field.getName();
	Object o = fieldsMap.get(fieldName, null);
	Field[] args;
	if (o == null) {
	    args = new Field[1];
	    fieldsMap.setEL(fieldName, args);
	}
	else {
	    Field[] fs = (Field[]) o;
	    args = new Field[fs.length + 1];
	    for (int i = 0; i < fs.length; i++) {
		fs[i].setAccessible(true);
		args[i] = fs[i];
	    }
	    fieldsMap.setEL(fieldName, args);
	}
	args[args.length - 1] = field;
    }
934453
def saveSettings(self):
        """"""
        self.settings.beginGroup('rampviewer')
        self.settings.setValue('geometry', self.saveGeometry())
        self.settings.endGroup()
1247434
def users_set_preferences(self, user_id, data, **kwargs):
        """"""
        return self.__call_api_post('users.setPreferences', userId=user_id, data=data, kwargs=kwargs)
1209622
def save(self, filename, verbose=False):
        
        with open(filename, 'w') as fid:
            json.dump(self._conf, fid, indent=4)
        if verbose:
            print('Saved settings in ' + filename)
518496
def save_cfror_fields(fields)
      fields.each do |field, value|
        field = Cfror::Field.find(field)
        field.save_value!(self, value)
      end
    end
1137170
def save(self, dolist=0):
        
        quoted = not dolist
        fields = 7*[""]
        fields[0] = self.name
        fields[1] = self.type
        fields[2] = self.mode
        fields[3] = self.toString(self.value,quoted=quoted)
        if self.choice is not None:
            schoice = list(map(self.toString, self.choice))
            schoice.insert(0,'')
            schoice.append('')
            fields[4] = repr('|'.join(schoice))
        elif self.min not in [None,INDEF]:
            fields[4] = self.toString(self.min,quoted=quoted)
        if self.max not in [None,INDEF]:
            fields[5] = self.toString(self.max,quoted=quoted)
        if self.prompt:
            if quoted:
                sprompt = repr(self.prompt)
            else:
                sprompt = self.prompt
            # prompt can have embedded newlines (which are printed)
            sprompt = sprompt.replace(r'\012', '\n')
            sprompt = sprompt.replace(r'\n', '\n')
            fields[6] = sprompt
        # delete trailing null parameters
        for i in [6,5,4]:
            if fields[i] != "": break
            del fields[i]
        if dolist:
            return fields
        else:
            return ','.join(fields)
76611
def OnPreferences(self, event):
        """"""

        preferences = self.interfaces.get_preferences_from_user()

        if preferences:
            for key in preferences:
                if type(config[key]) in (type(u""), type("")):
                    config[key] = preferences[key]
                else:
                    config[key] = ast.literal_eval(preferences[key])

        self.main_window.grid.grid_renderer.cell_cache.clear()
        self.main_window.grid.ForceRefresh()
1059505
public function save() {
        $configdata = $this->get('configdata');
        if (!array_key_exists('defaultvalue_editor', $configdata)) {
            $this->field->save();
            return;
        }

        if (!$this->get('id')) {
            $this->field->save();
        }

        // Store files.
        $textoptions = $this->value_editor_options();
        $tempvalue = (object) ['defaultvalue_editor' => $configdata['defaultvalue_editor']];
        $tempvalue = file_postupdate_standard_editor($tempvalue, 'defaultvalue', $textoptions, $textoptions['context'],
            'customfield_textarea', 'defaultvalue', $this->get('id'));

        $configdata['defaultvalue'] = $tempvalue->defaultvalue;
        $configdata['defaultvalueformat'] = $tempvalue->defaultvalueformat;
        unset($configdata['defaultvalue_editor']);
        $this->field->set('configdata', json_encode($configdata));
        $this->field->save();
    }
1132125
def save(self, **kwargs):
        
        entry = super(FormForForm, self).save(commit=False)
        entry.form = self.form
        entry.entry_time = now()
        entry.save()
        entry_fields = entry.fields.values_list("field_id", flat=True)
        new_entry_fields = []
        for field in self.form_fields:
            field_key = "field_%s" % field.id
            value = self.cleaned_data[field_key]
            if value and self.fields[field_key].widget.needs_multipart_form:
                value = fs.save(join("forms", str(uuid4()), value.name), value)
            if isinstance(value, list):
                value = ", ".join([v.strip() for v in value])
            if field.id in entry_fields:
                field_entry = entry.fields.get(field_id=field.id)
                field_entry.value = value
                field_entry.save()
            else:
                new = {"entry": entry, "field_id": field.id, "value": value}
                new_entry_fields.append(FieldEntry(**new))
        if new_entry_fields:
            FieldEntry.objects.bulk_create(new_entry_fields)
        return entry
15595
def save_default_values(self):
        """"""
        for parameter_container in self.default_value_parameter_containers:
            parameters = parameter_container.get_parameters()
            for parameter in parameters:
                set_inasafe_default_value_qsetting(
                    self.settings,
                    GLOBAL,
                    parameter.guid,
                    parameter.value
                )
900163
def save_metadata(self):
        """"""
        metadata = self.field_mapping_widget.get_field_mapping()
        for key, value in list(metadata['fields'].items()):
            # Delete the key if it's set to None
            if key in self.metadata['inasafe_default_values']:
                self.metadata['inasafe_default_values'].pop(key)
            if value is None or value == []:
                if key in self.metadata['inasafe_fields']:
                    self.metadata['inasafe_fields'].pop(key)
            else:
                self.metadata['inasafe_fields'][key] = value

        for key, value in list(metadata['values'].items()):
            # Delete the key if it's set to None
            if key in self.metadata['inasafe_fields']:
                self.metadata['inasafe_fields'].pop(key)
            if value is None:
                if key in self.metadata['inasafe_default_values']:
                    self.metadata['inasafe_default_values'].pop(key)
            else:
                self.metadata['inasafe_default_values'][key] = value

        # Save metadata
        try:
            self.keyword_io.write_keywords(
                layer=self.layer, keywords=self.metadata)
        except InaSAFEError as e:
            error_message = get_error_message(e)
            # noinspection PyCallByClass,PyTypeChecker,PyArgumentList
            QMessageBox.warning(
                self, self.tr('InaSAFE'),
                ((self.tr(
                    'An error was encountered when saving the following '
                    'keywords:\n %s') % error_message.to_html())))

        # Update setting fir recent value
        if self.metadata.get('inasafe_default_values'):
            for key, value in \
                    list(self.metadata['inasafe_default_values'].items()):
                set_inasafe_default_value_qsetting(
                    self.setting, key, RECENT, value)