Update multiple preferences at once

        this is a long method because we ensure everything is valid
        before actually persisting the changes
353092
def bulk(self, request, *args, **kwargs):
        
        manager = self.get_manager()
        errors = {}
        preferences = []
        payload = request.data

        # first, we check updated preferences actually exists in the registry
        try:
            for identifier, value in payload.items():
                try:
                    preferences.append(
                        self.queryset.model.registry.get(identifier))
                except exceptions.NotFoundInRegistry:
                    errors[identifier] = 'invalid preference'
        except (TypeError, AttributeError):
            return Response('invalid payload', status=400)

        if errors:
            return Response(errors, status=400)

        # now, we generate an optimized Q objects to retrieve all matching
        # preferences at once from database
        queries = [
            Q(section=p.section.name, name=p.name)
            for p in preferences
        ]

        query = queries[0]
        for q in queries[1:]:
            query |= q
        preferences_qs = self.get_queryset().filter(query)

        # next, we generate a serializer for each database preference
        serializer_objects = []
        for p in preferences_qs:
            s = self.get_serializer_class()(
                p, data={'value': payload[p.preference.identifier()]})
            serializer_objects.append(s)

        validation_errors = {}

        # we check if any serializer is invalid
        for s in serializer_objects:
            if s.is_valid():
                continue
            validation_errors[s.instance.preference.identifier()] = s.errors

        if validation_errors:
            return Response(validation_errors, status=400)

        for s in serializer_objects:
            s.save()

        return Response(
            [s.data for s in serializer_objects],
            status=200,
        )
16623
void update() {
        Application.update(filter, list, main, footer, toggleAll, count, clearCompleted);
    }
1134063
synchronized long userUpdate(long value) {

        if (value == currValue) {
            currValue += increment;

            return value;
        }

        if (increment > 0) {
            if (value > currValue) {
                currValue += ((value - currValue + increment) / increment)
                             * increment;
            }
        } else {
            if (value < currValue) {
                currValue += ((value - currValue + increment) / increment)
                             * increment;
            }
        }

        return value;
    }
1369837
def refresh(self, key):
        """"""
        s0 = self[key]
        s = self.backtrack(key)
        s.persist(**s0.metadata['persist_kwargs'])
201214
def merge_config(self, user_config):
        '''
        
        '''

        # provisioanlly update the default configurations with the user preferences
        temp_data_config = copy.deepcopy(self.data_config).update(user_config)
        temp_model_config = copy.deepcopy(self.model_config).update(user_config)
        temp_conversation_config = copy.deepcopy(self.conversation_config).update(user_config)

        # if the new configurations validate, apply them
        if validate_data_config(temp_data_config):
            self.data_config = temp_data_config
        if validate_model_config(temp_model_config):
            self.model_config = temp_model_config
        if validate_conversation_config(temp_conversation_config):
            self.conversation_config = temp_conversation_config
1125358
def set_preferences(self, user=None, **kwargs):
        """"""
        if user is None:
            user = current_user

        d = {pref.key: pref for pref in user.preferences}
        for k, v in kwargs.items():
            if k in d:
                d[k].value = v
            else:
                d[k] = UserPreference(user=user, key=k, value=v)
                db.session.add(d[k])
1201427
public void putLong(String key, long value) {
		sharedPreferences.edit().putLong(key, value).commit();
	}
891676
function preferencesReload() {
    return this.initializedPromise.then(function () {
      this._readFromStorage(DEFAULT_PREFERENCES).then(function(prefObj) {
        if (prefObj) {
          this.prefs = prefObj;
        }
      }.bind(this));
    }.bind(this));
  }
939096
private void initializeShowMultipleChoiceListDialogPreference() {
        Preference preference =
                findPreference(getString(R.string.show_multi_choice_dialog_preference_key));
        preference.setOnPreferenceClickListener(new OnPreferenceClickListener() {

            @Override
            public boolean onPreferenceClick(final Preference preference) {
                initializeMultipleChoiceListDialog();
                multipleChoiceListDialog
                        .setShowAnimation(createRectangularRevealAnimation(preference));
                multipleChoiceListDialog
                        .setDismissAnimation(createRectangularRevealAnimation(preference));
                multipleChoiceListDialog
                        .setCancelAnimation(createRectangularRevealAnimation(preference));
                multipleChoiceListDialog.show();
                return true;
            }

        });
    }
203726
def update(self, defaults=values.unset):
        
        data = values.of({'Defaults': serialize.object(defaults), })

        payload = self._version.update(
            'POST',
            self._uri,
            data=data,
        )

        return DefaultsInstance(self._version, payload, assistant_sid=self._solution['assistant_sid'], )
302313
def _update_defaults(self, defaults, old_version, verbose=False):
        """"""
        old_defaults = self._load_old_defaults(old_version)
        for section, options in defaults:
            for option in options:
                new_value = options[ option ]
                try:
                    old_value = old_defaults.get(section, option)
                except (cp.NoSectionError, cp.NoOptionError):
                    old_value = None
                if old_value is None or \
                  to_text_string(new_value) != old_value:
                    self._set(section, option, new_value, verbose)
592697
def set_default_preferences(self):
        

        LOGGER.debug("> Initializing default settings!")

        for key in self.__default_settings.allKeys():
            self.__settings.setValue(key, self.__default_settings.value(key))

        self.set_default_layouts()
        return True
707520
public function initializeUpdateAction()
    {
        $propertyMappingConfiguration = $this->arguments->getArgument('workspace')->getPropertyMappingConfiguration();
        $propertyMappingConfiguration->allowProperties('name', 'baseWorkspace');
        $propertyMappingConfiguration->setTypeConverterOption(PersistentObjectConverter::class, PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED, true);
    }
1159373
def update(cls, settings):
        """"""
        for key, val in settings.__dict__.items():
            if key.startswith('_'):
                continue
            setattr(cls, key, val)
124210
def update(self, **kwargs):
        
        # Override the template values with the override values.
        for s in config.sections():
            for o in config.options(s):
                override = kwargs.pop(o, None)
                if override:
                    config.set(s, o, override)
540871
function (configData, platform) {
            var preferences = this.getPreferences(platform),
                type = 'preference';

            _.each(preferences, function (preference) {
                var prefMappingData = preferenceMappingData[platform][preference.attrib.name],
                    target,
                    prefData;

                if (prefMappingData) {
                    prefData = {
                        parent: prefMappingData.parent,
                        type: type,
                        destination: prefMappingData.destination,
                        data: preference
                    };

                    target = prefMappingData.target;
                    if(!configData[target]) {
                        configData[target] = [];
                    }
                    configData[target].push(prefData);
                }
            });
        }
1232746
synchronized long systemUpdate(long value) {

        if (value == currValue) {
            currValue += increment;

            return value;
        }

        if (increment > 0) {
            if (value > currValue) {
                currValue = value + increment;
            }
        } else {
            if (value < currValue) {
                currValue = value + increment;
            }
        }

        return value;
    }