Prepares a service to manage documents in the provided collection. This service will be set up by the Amity server.
503189
function(collection, callback){
  	// Prep the collection name.
  	var colName = collection.name.split('.');
  	var dbName = colName.shift();
  	colName = colName.join('.');

  	var database = amityMongo.db.db(dbName);

  	var options = {
  		name:dbName + '/' + colName,
  		service:feathersMongo({collection:database.collection(collection.name)})
  	};
  	amityMongo.amity_collections.push(options);
  	callback();
	}
856385
protected function prepareDocument()
	{
		$app   = JFactory::getApplication();
		$menus = $app->getMenu();

		// Because the application sets a default page title, we need to get it from the menu item itself
		$menu = $menus->getActive();

		if ($menu)
		{
			$this->params->def('page_heading', $this->params->get('page_title', $menu->title));
		}
		else
		{
			$this->params->def('page_heading', JText::_($this->pageHeading));
		}

		$title = $this->params->get('page_title', '');

		if (empty($title))
		{
			$title = $app->get('sitename');
		}
		elseif ($app->get('sitename_pagetitles', 0) == 1)
		{
			$title = JText::sprintf('JPAGETITLE', $app->get('sitename'), $title);
		}
		elseif ($app->get('sitename_pagetitles', 0) == 2)
		{
			$title = JText::sprintf('JPAGETITLE', $title, $app->get('sitename'));
		}

		$this->document->setTitle($title);

		if ($this->params->get('menu-meta_description'))
		{
			$this->document->setDescription($this->params->get('menu-meta_description'));
		}

		if ($this->params->get('menu-meta_keywords'))
		{
			$this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
		}

		if ($this->params->get('robots'))
		{
			$this->document->setMetadata('robots', $this->params->get('robots'));
		}
	}
618837
@Override
  public RecordMaterializer<T> prepareForRead(Configuration configuration,
                                              Map<String, String> keyValueMetaData, MessageType fileSchema,
                                              ReadSupport.ReadContext readContext) {
    ThriftMetaData thriftMetaData = ThriftMetaData.fromExtraMetaData(keyValueMetaData);
    try {
      if (thriftClass == null) {
        thriftClass = getThriftClass(keyValueMetaData, configuration);
      }

      ThriftType.StructType descriptor = null;
      if (thriftMetaData != null) {
        descriptor = thriftMetaData.getDescriptor();
      } else {
        ScroogeStructConverter schemaConverter = new ScroogeStructConverter();
        descriptor = schemaConverter.convert(thriftClass);
      }

      ThriftRecordConverter<T> converter = new ScroogeRecordConverter<T>(
        thriftClass,
        readContext.getRequestedSchema(),
        descriptor);
      return converter;
    } catch (Exception t) {
      throw new RuntimeException("Unable to create Thrift Converter for Thrift metadata " + thriftMetaData, t);
    }
  }
480259
protected function _prepareCollection()
    {
        /** @var Aoe_Scheduler_Model_Resource_Job_Collection $collection */
        $collection = Mage::getSingleton('aoe_scheduler/job')->getCollection();
        $this->setCollection($collection);
        return parent::_prepareCollection();
    }
636754
public function prepare()
    {

        $blocks = $this->container->getBlocks();
        $fields = array_merge($this->container->getFields() , $this->container->getImages());

        $this->declareListOfBlocks($blocks)
                ->declareListOfValues($fields);

        return $this->createDocument();
    }
453489
def handle_services(changeset):
    """"""
    charms = {}
    for service_name, service in sorted(changeset.bundle['services'].items()):
        # Add the addCharm record if one hasn't been added yet.
        if service['charm'] not in charms:
            record_id = 'addCharm-{}'.format(changeset.next_action())
            changeset.send({
                'id': record_id,
                'method': 'addCharm',
                'args': [service['charm']],
                'requires': [],
            })
            charms[service['charm']] = record_id

        # Add the deploy record for this service.
        record_id = 'deploy-{}'.format(changeset.next_action())
        changeset.send({
            'id': record_id,
            'method': 'deploy',
            'args': [
                '${}'.format(charms[service['charm']]),
                service_name,
                service.get('options', {}),
                service.get('constraints', ''),
                service.get('storage', {}),
            ],
            'requires': [charms[service['charm']]],
        })
        changeset.services_added[service_name] = record_id

        # Expose this service if required.
        if service.get('expose'):
            changeset.send({
                'id': 'expose-{}'.format(changeset.next_action()),
                'method': 'expose',
                'args': ['${}'.format(record_id)],
                'requires': [record_id],
            })

        # Set the annotations for this service.
        if 'annotations' in service:
            changeset.send({
                'id': 'setAnnotations-{}'.format(changeset.next_action()),
                'method': 'setAnnotations',
                'args': [
                    '${}'.format(record_id),
                    'service',
                    service['annotations'],
                ],
                'requires': [record_id],
            })

    return handle_machines
74157
def add_documents(self, docs):
        
        for sent in docs:
            sent = map(self.process_token, sent)
            self._token_count.update(sent)
891921
public Document serviceToDocument() {
        final AtomService service = this;

        final Document doc = new Document();
        final Element root = new Element("service", ATOM_PROTOCOL);
        doc.setRootElement(root);
        final List<Workspace> spaces = service.getWorkspaces();
        for (final Workspace space : spaces) {
            root.addContent(space.workspaceToElement());
        }
        return doc;
    }
1247795
protected function _prepareCollection()
    {
        /** @var Mage_Cron_Model_Resource_Schedule_Collection $collection */
        $collection = Mage::getModel('cron/schedule')->getCollection();
        $this->setCollection($collection);
        return parent::_prepareCollection();
    }
720352
def configure_createcollection(self, ns, definition):
        
        paginated_list_schema = self.page_cls.make_paginated_list_schema_class(
            ns,
            definition.response_schema,
        )()

        @self.add_route(ns.collection_path, Operation.CreateCollection, ns)
        @request(definition.request_schema)
        @response(paginated_list_schema)
        @wraps(definition.func)
        def create_collection(**path_data):
            request_data = load_request_data(definition.request_schema)
            # NB: if we don't filter the request body through an explicit page schema,
            # we will leak other request arguments into the pagination query strings
            page = self.page_cls.from_query_string(self.page_schema(), request_data)

            result = definition.func(**merge_data(
                path_data,
                merge_data(
                    request_data,
                    page.to_dict(func=identity),
                ),
            ))

            response_data, headers = page.to_paginated_list(result, ns, Operation.CreateCollection)
            definition.header_func(headers, response_data)
            response_format = self.negotiate_response_content(definition.response_formats)
            return dump_response_data(
                paginated_list_schema,
                response_data,
                headers=headers,
                response_format=response_format,
            )

        create_collection.__doc__ = "Create the collection of {}".format(pluralize(ns.subject_name))
33023
function prepareDOM() {
        var i, pageNum,
            zoomLevel, maxZoom,
            ptWidth, ptHeight,
            pxWidth, pxHeight,
            pt2px = util.calculatePtSize(),
            dimensions = config.metadata.dimensions,
            skeleton = '';

        // adjust page scale if the pages are too small/big
        // it's adjusted so 100% == DOCUMENT_100_PERCENT_WIDTH px;
        config.pageScale = DOCUMENT_100_PERCENT_WIDTH / (dimensions.width * pt2px);

        // add zoom levels to accomodate the scale
        zoomLevel = config.zoomLevels[config.zoomLevels.length - 1];
        maxZoom = 3 / config.pageScale;
        while (zoomLevel < maxZoom) {
            zoomLevel += zoomLevel / 2;
            config.zoomLevels.push(zoomLevel);
        }

        dimensions.exceptions = dimensions.exceptions || {};

        // create skeleton
        for (i = config.pageStart - 1; i < config.pageEnd; i++) {
            pageNum = i + 1;
            if (pageNum in dimensions.exceptions) {
                ptWidth = dimensions.exceptions[pageNum].width;
                ptHeight = dimensions.exceptions[pageNum].height;
            } else {
                ptWidth = dimensions.width;
                ptHeight = dimensions.height;
            }
            pxWidth = ptWidth * pt2px;
            pxHeight = ptHeight * pt2px;
            pxWidth *= config.pageScale;
            pxHeight *= config.pageScale;
            skeleton += util.template(Crocodoc.pageTemplate, {
                w: pxWidth,
                h: pxHeight
            });
        }

        // insert skeleton and keep a reference to the jq object
        config.$pages = $(skeleton).appendTo(config.$doc);
    }
809254
protected function build()
    {
        $operation = $this->buildOperation('ListPaymentMethods');

        $merchantID = $this->document->createElement('merchantID', $this->merchantId);
        $operation->appendChild($merchantID);

        if ($this->pType) {
            $pType = $this->document->createElement('pType', $this->pType);
            $operation->appendChild($pType);
        }
    }
1374433
function(database, callback){
		var dbName = database.databaseName || database.name;
		var options = {
			name:dbName + '/_collections',
			service:feathersMongoColls(amityMongo.db.db(dbName))
		};
		amityMongo.amity_collManager.push(options);
		callback();
	}
378564
def add_new_collection(self,
                           owner_id,
                           json_repr,
                           auth_info,
                           collection_id=None,
                           commit_msg=''):
        """"""
        collection = self._coerce_json_to_collection(json_repr)
        if collection is None:
            msg = "File failed to parse as JSON:\n{j}".format(j=json_repr)
            raise ValueError(msg)
        if not self._is_valid_collection_json(collection):
            msg = "JSON is not a valid collection:\n{j}".format(j=json_repr)
            raise ValueError(msg)
        if collection_id:
            # try to use this id
            found_owner_id, slug = collection_id.split('/')
            assert found_owner_id == owner_id
        else:
            # extract a working title and "slugify" it
            slug = self._slugify_internal_collection_name(json_repr)
            collection_id = '{i}/{s}'.format(i=owner_id, s=slug)
        # Check the proposed id for uniqueness in any case. Increment until
        # we have a new id, then "reserve" it using a placeholder value.
        with self._index_lock:
            while collection_id in self._doc2shard_map:
                collection_id = increment_slug(collection_id)
            self._doc2shard_map[collection_id] = None
        # pass the id and collection JSON to a proper git action
        new_collection_id = None
        r = None
        try:
            # assign the new id to a shard (important prep for commit_and_try_merge2master)
            gd_id_pair = self.create_git_action_for_new_collection(new_collection_id=collection_id)
            new_collection_id = gd_id_pair[1]
            try:
                # let's remove the 'url' field; it will be restored when the doc is fetched (via API)
                del collection['url']
                # keep it simple (collection is already validated! no annotations needed!)
                r = self.commit_and_try_merge2master(file_content=collection,
                                                     doc_id=new_collection_id,
                                                     auth_info=auth_info,
                                                     parent_sha=None,
                                                     commit_msg=commit_msg,
                                                     merged_sha=None)
            except:
                self._growing_shard.delete_doc_from_index(new_collection_id)
                raise
        except:
            with self._index_lock:
                if new_collection_id in self._doc2shard_map:
                    del self._doc2shard_map[new_collection_id]
            raise
        with self._index_lock:
            self._doc2shard_map[new_collection_id] = self._growing_shard
        return new_collection_id, r
161722
private void setup(Collection<T> items, int ps, Comparator<T> sort) {
		Collection<T> list;
		Iterator<T> it;

		if( sort == null ) {
			list = items;
		}
		else {
			list = new TreeSet<T>(sort);
			list.addAll(items);			
		}
		sorter = sort;
		pageSize = ps;
        pages = new ArrayList<Collection<T>>();
		it = list.iterator();		
		while( it.hasNext() ) {
			ArrayList<T> page = new ArrayList<T>();
			
			pages.add(page);
			for(int i=0; i<ps; i++ ) {
                T ob;
                
				if( !it.hasNext() ) {
					break;
				}
                ob = it.next();
				page.add(ob);
			}
		}
	}
185571
function prepareResponse(validDataSources, invalidDataSources, cb) {
  //There Were Errors Updating Data Sources, should return an error

  logger.debug("prepareResponse Before", validDataSources);
  //For The Valid Data Sources, Just want the updated Document JSON
  validDataSources = _.map(validDataSources, function(validDataSourceData) {
    return processDataSourceResponse(validDataSourceData.document.toJSON());
  });

  logger.debug("prepareResponse After", validDataSources);

  var returnError;
  if (invalidDataSources.length > 0) {
    returnError = buildErrorResponse({
      error: new Error("Error Updating Data Sources"),
      code: ERROR_CODES.FH_FORMS_UNEXPECTED_ERROR
    });
  }

  return cb(returnError, {
    validDataSourceUpdates: validDataSources,
    invalidDataSourceUpdates: invalidDataSources
  });
}
217084
public static AtomService documentToService(final Document document) throws ProponoException {
        final AtomService service = new AtomService();
        final Element root = document.getRootElement();
        final List<Element> spaces = root.getChildren("workspace", ATOM_PROTOCOL);
        for (final Element e : spaces) {
            service.addWorkspace(Workspace.elementToWorkspace(e));
        }
        return service;
    }