Update or create design doc with supplied views

 @since 1.2.0

 @param [Hash, IO, String] data The source object containing JSON
   encoded design document. It must have +_id+ key set, this key
   should start with +_design/+.

 @return [true, false]
438195
def save_design_doc(data)
      attrs = case data
              when String
                MultiJson.load(data)
              when IO
                MultiJson.load(data.read)
              when Hash
                data
              else
                raise ArgumentError, "Document should be Hash, String or IO instance"
              end
      id = attrs.delete('_id').to_s
      attrs['language'] ||= 'javascript'
      raise ArgumentError, "'_id' key must be set and start with '_design/'." if id !~ /\A_design\//
      res = __http_query(:view, :put, "/#{id}", MultiJson.dump(attrs), 'application/json', nil, nil, nil)
      return true if res[:status] == 201
      val = MultiJson.load(res[:chunks].join)
      raise Error::View.new("save_design_doc", val['error'])
    end
1229437
def data=(data)
      raise "not yet used"
      raise "Data nil or invalid" if data.nil? or data.size == 0
      delete_all
      @data = data
      tme = TreeModelEvent.new(0, @data.length-1,:ALL_COLUMNS,  self, :INSERT)
      fire_handler :TREE_MODEL_EVENT, tme
    end
1158669
def new
      @snippet = Snippet.new

      respond_to do |format|
        format.html # new.html.erb
        format.json { render json: @snippet }
      end
    end
424796
function(data){
      if (this.delegate)
        return this.root.update(data);

      if (data)
      {
        var delta = {};
        var changed = false;

        for (var prop in data)
          if (this.data[prop] !== data[prop])
          {
            changed = true;
            delta[prop] = this.data[prop];
            this.data[prop] = data[prop];
          }

        if (changed)
        {
          this.emit_update(delta);
          return delta;
        }
      }

      return false;
    }
1345289
function(args, callback) {
      // Make sure the ID exists
      var t = this, model = args.model;
      if (!model || !model.id) {
        return callback({msg:'SyncProbe create - Data model with ID not present'});
      }

      // Make sure the file doesn't already exist
      t.getFullPath(model.id, function(error, response) {
        if (error) {
          return callback(error);
        }

        if (response.stats) {
          return callback({msg:'Document with this ID already exists'});
        }

        // Forward to the update control
        t.update_control(args, callback);
      });
    }
1127348
def view_create(self, data, **kwargs):
        ""
        api_path = "/api/v2/views.json"
        return self.call(api_path, method="POST", data=data, **kwargs)
665402
def data
      templates = @templates.deep_clone

      templates.each_pair do |name, value|
        if value['bindings']
          value['bindings'].each_pair do |number, binding|
            value['bindings'][number] = binding.map { |code| eval(code) }
          end
        end
      end

      templates
    end
372145
public boolean createOrUpdateData(String indexName, String type, String id, Object obj) {
        IndexResponse response = getClient().prepareIndex(indexName, type).setId(id).setSource(Lang.obj2map(obj)).execute().actionGet();
        return response.getResult() == DocWriteResponse.Result.CREATED || response.getResult() == DocWriteResponse.Result.UPDATED;
    }
103448
def update
      @element = Humpyard::Element.find(params[:id])
      if @element
        unless can? :update, @element
          render :json => {
            :status => :failed
          }, :status => 403
          return
        end
        
        if @element.content_data.update_attributes params[:element]
          render :json => {
            :status => :ok,
            :dialog => :close,
            :replace => [
              { 
                :element => "hy-id-#{@element.id}",
                :url => humpyard_element_path(@element)
              }
            ]
          }
        else
          render :json => {
            :status => :failed, 
            :errors => @element.content_data.errors
          }
        end
      else
        render :json => {
          :status => :failed
        }, :status => 404
      end
    end
319678
protected Map<String, Object> bytesMapToDocument(Map<String, byte[]> data) {
        if (data == null || data.size() == 0) {
            return null;
        }
        Map<String, Object> doc = new HashMap<>();
        data.forEach((k, v) -> {
            Object value = SerializationUtils.fromByteArrayFst(v);
            if (value != null) {
                doc.put(k, value);
            }
        });
        return doc;
    }
341445
function Table(options, data) {
        options = options || {};

        // Updates indexes on the fly.
        if (!options.update) options.update = {};

        if ('undefined' === typeof options.update.indexes) {
            options.update.indexes = true;
        }

        NDDB.call(this, options, data);

//         // ### Table.row
//         // NDDB hash containing elements grouped by row index
//         // @see NDDB.hash
//         if (!this.row) {
//             this.hash('row', function(c) {
//                 return c.x;
//             });
//         }
//
//         // ### Table.col
//         // NDDB hash containing elements grouped by column index
//         // @see NDDB.hash
//         if (!this.col) {
//             this.hash('col', function(c) {
//                 return c.y;
//             });
//         }

        // ### Table.rowcol
        // NDDB index to access elements with row.col notation
        // @see NDDB.hash
        if (!this.rowcol) {
            this.index('rowcol', function(c) {
                return c.x + '.' + c.y;
            });
        }

        /**
         * ### Table.pointers
         *
         * References to last inserted cell coordinates
         */
        this.pointers = {
            x: options.pointerX || null,
            y: options.pointerY || null
        };

        /**
         * ### Table.header
         *
         * Array containing the header elements of the table
         */
        this.header = [];

        /**
         * ### Table.footer
         *
         * Array containing the footer elements of the table
         */
        this.footer = [];

        /**
         * ### Table.left
         *
         * Array containing elements to keep on the left border of the table
         */
        this.left = [];

        /**
         * ### Table.table
         *
         * Reference to the HTMLElement Table
         */
        this.table = options.table || document.createElement('table');

        if ('string' === typeof options.id) {
            this.table.id = options.id;
        }
        else if (options.id) {
            throw new TypeError('Table constructor: options.id must be ' +
                                'string or undefined.');
        }

        if ('string' === typeof options.className) {
            this.table.className = options.className;
        }
        else if (J.isArray(options.className)) {
            this.table.className = options.className.join(' ');
        }
        else if (options.className) {
            throw new TypeError('Table constructor: options.className must ' +
                                'be string, array, or undefined.');
        }

        /**
         * ### Table.missingClassName
         *
         * Class name for "missing" cells
         *
         * "Missing" cells are cells that are added automatically to complete
         * the table because one or more cells have been added with higher
         * row and column indexes.
         */
        this.missingClassName = 'missing';

        if ('string' === typeof options.missingClassName) {
            this.missingClassName = options.missingClassName;
        }
        else if (J.isArray(options.missingClassName)) {
            this.missingClassName = options.missingClassName.join(' ');
        }
        else if (options.missingClassName) {
            throw new TypeError('Table constructor: options.className must ' +
                                'be string, array, or undefined.');
        }

        /**
         * ### Table.autoParse
         *
         * If TRUE, whenever a new cell is added the table is updated.
         * Default: FALSE
         */
        this.autoParse = 'undefined' !== typeof options.autoParse ?
            options.autoParse : false;

        /**
         * ### Table.trs
         *
         * List of TR elements indexed by their order in the parsed table
         */
        this.trs = {};

        /**
         * ### Table.trCb
         *
         * Callback function applied to each TR HTML element
         *
         * Callback receives the HTML element, and the row index, or
         * 'thead' and 'tfoot' for header and footer.
         */
        if ('function' === typeof options.tr) {
            this.trCb = options.tr;
        }
        else if ('undefined' === typeof options.tr) {
            this.trCb = null;
        }
        else {
            throw new TypeError('Table constructor: options.tr must be ' +
                                'function or undefined.');
        }

        // Init renderer.
        this.initRenderer(options.render);
    }
1026764
@Transactional
    @Override
    public void importData(ExternalStylesheetDescriptor data) {
        final String stylesheetName = data.getName();
        final String uri = data.getUri();

        IStylesheetDescriptor stylesheetDescriptor =
                this.stylesheetDescriptorDao.getStylesheetDescriptorByName(stylesheetName);
        if (stylesheetDescriptor == null) {
            stylesheetDescriptor =
                    this.stylesheetDescriptorDao.createStylesheetDescriptor(stylesheetName, uri);
        } else {
            stylesheetDescriptor.setStylesheetResource(uri);
        }

        stylesheetDescriptor.setUrlNodeSyntaxHelperName(data.getUrlSyntaxHelper());
        stylesheetDescriptor.setDescription(data.getDescription());

        final List<ExternalOutputPropertyDescriptor> extOutputProperties =
                data.getOutputProperties();
        final List<IOutputPropertyDescriptor> outputPropertyDescriptors =
                new ArrayList<IOutputPropertyDescriptor>(extOutputProperties.size());
        for (final ExternalOutputPropertyDescriptor extOutputProperty : extOutputProperties) {
            final String name = extOutputProperty.getName();
            final Scope scope = Scope.valueOf(extOutputProperty.getScope().name());
            final OutputPropertyDescriptorImpl outputPropertyDescriptor =
                    new OutputPropertyDescriptorImpl(name, scope);
            outputPropertyDescriptor.setDefaultValue(extOutputProperty.getDefaultValue());
            outputPropertyDescriptor.setDescription(extOutputProperty.getDescription());

            outputPropertyDescriptors.add(outputPropertyDescriptor);
        }
        stylesheetDescriptor.setOutputPropertyDescriptors(outputPropertyDescriptors);

        final List<ExternalStylesheetParameterDescriptor> extStylesheetParameters =
                data.getStylesheetParameters();
        final List<IStylesheetParameterDescriptor> stylesheetParameterDescriptors =
                new ArrayList<IStylesheetParameterDescriptor>(extOutputProperties.size());
        for (final ExternalStylesheetParameterDescriptor extStylesheetParameter :
                extStylesheetParameters) {
            final String name = extStylesheetParameter.getName();
            final Scope scope = Scope.valueOf(extStylesheetParameter.getScope().name());
            final StylesheetParameterDescriptorImpl stylesheetParameterDescriptor =
                    new StylesheetParameterDescriptorImpl(name, scope);
            stylesheetParameterDescriptor.setDefaultValue(extStylesheetParameter.getDefaultValue());
            stylesheetParameterDescriptor.setDescription(extStylesheetParameter.getDescription());

            stylesheetParameterDescriptors.add(stylesheetParameterDescriptor);
        }
        stylesheetDescriptor.setStylesheetParameterDescriptors(stylesheetParameterDescriptors);

        final List<ExternalLayoutAttributeDescriptor> extLayoutAttributes =
                data.getLayoutAttributes();
        final List<ILayoutAttributeDescriptor> layoutAttributeDescriptors =
                new ArrayList<ILayoutAttributeDescriptor>(extOutputProperties.size());
        for (final ExternalLayoutAttributeDescriptor extLayoutAttribute : extLayoutAttributes) {
            final String name = extLayoutAttribute.getName();
            final Scope scope = Scope.valueOf(extLayoutAttribute.getScope().name());
            final LayoutAttributeDescriptorImpl layoutAttributeDescriptor =
                    new LayoutAttributeDescriptorImpl(name, scope);
            layoutAttributeDescriptor.setDefaultValue(extLayoutAttribute.getDefaultValue());
            layoutAttributeDescriptor.setDescription(extLayoutAttribute.getDescription());
            layoutAttributeDescriptor.setTargetElementNames(
                    new LinkedHashSet<String>(extLayoutAttribute.getTargetElements()));

            layoutAttributeDescriptors.add(layoutAttributeDescriptor);
        }
        stylesheetDescriptor.setLayoutAttributeDescriptors(layoutAttributeDescriptors);

        this.stylesheetDescriptorDao.updateStylesheetDescriptor(stylesheetDescriptor);
    }
899458
def do_load(self, design, init=False):
        # type: (str, bool) -> None
        
        if design:
            filename = self._validated_config_filename(design)
            with open(filename, "r") as f:
                text = f.read()
            structure = json_decode(text)
        else:
            structure = {}
        # Attributes and Children used to be merged, support this
        attributes = structure.get("attributes", structure)
        children = structure.get("children", structure)
        # Set the layout table
        name, mri, x, y, visible = [], [], [], [], []
        for part_name, d in attributes.get("layout", {}).items():
            name.append(part_name)
            mri.append("")
            x.append(d["x"])
            y.append(d["y"])
            visible.append(d["visible"])
        self.set_layout(LayoutTable(name, mri, x, y, visible))
        # Set the exports table
        source, export = [], []
        for source_name, export_name in attributes.get("exports", {}).items():
            source.append(source_name)
            export.append(export_name)
        self.exports.set_value(ExportTable(source, export))
        # Set other attributes
        our_values = {k: v for k, v in attributes.items()
                      if k in self.our_config_attributes}
        block = self.block_view()
        block.put_attribute_values(our_values)
        # Run the load hook to get parts to load their own structure
        self.run_hooks(
            LoadHook(p, c, children.get(p.name, {}), init)
            for p, c in self.create_part_contexts(only_visible=False).items())
        self._mark_clean(design, init)
812476
def update(data)
      update_avatar(data['avatar_url']) if data.key? 'avatar_url'
      update_displayname(data['displayname']) if data.key? 'displayname'
    end
73830
def set_data(self, data):
        
        # Make sure a dict got passed it
        if not isinstance(data, type({})):
            raise TypeError("This attribute must be a dictionary.")
        # Set the attribute
        self.__dict__['data'] = DocumentDataDict(data)
1181437
function(data) {
        this.features = [];
        this.styles   = {};
        this.fetched  = {};

        // Set default options 
        var options = {
            depth: 0,
            styleBaseUrl: this.styleBaseUrl
        };

        return this.parseData(data, options);
    }
915791
function buildViewAttribsFire( def, code ) {
    code.pm = true;
    const attribs = def[ "view.attribs" ];
    if ( typeof attribs !== 'object' ) return;
    try {
        for ( const attName of Object.keys( attribs ) ) {
            const camelCaseAttName = camelCase( attName );
            if ( !code.isAction( attName ) ) {
                buildViewAttribsInitFire( camelCaseAttName, code );
            }
        }
    } catch ( ex ) {
        bubble( ex, `...in buildViewAttribsFire - view.attribs: ${JSON.stringify(attribs, null, "  ")}` );
    }
}