ClientModelDocItemsController constructor
553464
function ClientModelDocItemsController($state) {
    var vm = this;

    // the selected item id
    var curClientModelDocId = null;

    // check if this item is selected
    vm.isSelected = isSelected;
    // switch to the detail state
    vm.showInDetails = showInDetails;

    /**
     * Check if the passed item is the current selected item
     *
     * @param {Object} clientModelDoc - The object to check for selection
     */
    function isSelected(clientModelDoc) {
      return curClientModelDocId === clientModelDoc._id;
    }

    /**
     * Open the detail state with the selected item
     *
     * @param {Object} clientModelDoc - The clientModelDoc to edit
     */
    function showInDetails(clientModelDoc) {
      curClientModelDocId = clientModelDoc._id;
      $state.go('clientModelDoc.list.detail', {'id': curClientModelDocId});
    }
  }
244784
function createControllerFunction(func) {

  var Handlebars = protos.require('handlebars');
  var context, newFunc, compile, source,
      funcSrc = func.toString();
  var code = funcSrc
      .trim()
      .replace(/^function\s+(.*?)(\s+)?\{(\s+)?/, '')
      .replace(/(\s+)?\}$/, '');

  // Get source file path
  var alias = protos.lib.controller.prototype.getAlias(func.name),
      srcFile = this.mvcpath + 'controllers/' + alias + '.js';

  try {
    source = fs.readFileSync(srcFile, 'utf-8');
  } catch(e){
    source = fs.readFileSync(srcFile.replace(/\.js$/, '_controller.js'), 'utf-8');
  }

  // Detect pre & post function code
  var si = source.indexOf(funcSrc),
      preFuncSrc = source.slice(0, si).trim(),
      postFuncSrc = source.slice(si + funcSrc.length).trim();

  // Controller code

  var template = Handlebars.compile('\n\
with (locals) {\n\n\
function {{{name}}}(app) {\n\
  this.filters = this.filters["{{{name}}}"] || [];\n\
}\n\n\
require("util").inherits({{{name}}}, protos.lib.controller);\n\n\
protos.extend({{{name}}}, protos.lib.controller);\n\n\
{{{name}}}.filter = {{{name}}}.prototype.filter;\n\
{{{name}}}.handler = {{{name}}}.prototype.handler;\n\n\
var __funKeys__ = Object.keys({{{name}}});\n\
\n\
(function() { \n\
{{{preFuncSrc}}}\n\n\
with(this) {\n\n\
  {{{code}}}\n\
}\n\n\
{{{postFuncSrc}}}\n\n\
}).call({{{name}}});\n\n\
for (var key in {{{name}}}) {\n\
  if (__funKeys__.indexOf(key) === -1) { \n\
    {{{name}}}.prototype[key] = {{{name}}}[key];\n\
    delete {{{name}}}[key];\n\
  }\n\
}\n\
\n\
if (!{{{name}}}.prototype.authRequired) {\n\
  {{{name}}}.prototype.authRequired = protos.lib.controller.prototype.authRequired;\n\
} else {\n\
  {{{name}}}.prototype.authRequired = true; \n\
}\n\n\
return {{{name}}};\n\n\
}');

  var fnCode = template({
    name: func.name,
    code: code,
    preFuncSrc: preFuncSrc,
    postFuncSrc: postFuncSrc,
  });

  // console.exit(fnCode);

  /*jshint evil:true */
  compile = new Function('locals', fnCode);

  newFunc = compile({
    app: this,
    protos: protos,
    module: {},
    require: require,
    console: console,
    __dirname: this.mvcpath + 'controllers',
    __filename: srcFile,
    process: process
  });

  return newFunc;

}
1186610
@Override
	public ApiDoc initApiDoc(Class<?> controller) {
		ApiDoc apiDoc = new ApiDoc();
		apiDoc.setName(controller.getSimpleName());
		apiDoc.setDescription(controller.getSimpleName());
		return apiDoc;
	}
183502
public void createControlAdapter()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.entry(tc, "createControlAdapter");
    
    controlAdapter = new MQLinkQueuePoint(destinationHandler.getMessageProcessor(), this);
    
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.exit(tc, "createControlAdapter");
  }
392576
@Override
    public void visit(ControllerModel element, Raml raml) {
        raml.setTitle(element.getName());

        if (element.getDescription() != null && !element.getDescription().isEmpty()) {
            DocumentationItem doc = new DocumentationItem();
            doc.setContent(element.getDescription());
            doc.setTitle("Description");
            raml.setDocumentation(singletonList(doc));
        }

        if (element.getVersion() != null && !element.getVersion().isEmpty()) {
            raml.setVersion(element.getVersion());
        }

        //noinspection unchecked
        navigateTheRoutes(element.getRoutes(), null, raml);
    }
964836
public void displayNewModelPage(CmsModelPageEntry modelPageData, boolean isModelGroup) {

        CmsModelPageTreeItem treeItem = new CmsModelPageTreeItem(modelPageData, isModelGroup, false);
        CmsSitemapHoverbar.installOn(
            m_controller,
            treeItem,
            modelPageData.getStructureId(),
            modelPageData.getSitePath(),
            modelPageData.getSitePath() != null);
        m_modelPageTreeItems.put(modelPageData.getStructureId(), treeItem);
        if (isModelGroup) {
            m_modelGroupRoot.addChild(treeItem);
        } else {
            m_modelPageRoot.addChild(treeItem);
        }
    }
921473
function getTemplateModel(prefix, resource, appName) {
    var methods = {};

    // if no api or browser apiclient, then return null since we will skip
    if (!resource.api || resource.adapters.browser !== 'apiclient') {
        return null;
    }

    // loop through API routes and create method objects for the template
    _.each(resource.api, function (urlMappings, httpMethod) {
        _.each(urlMappings, function (methodName, url) {
            methods[methodName] = {
                httpMethod: httpMethod,
                url: url
            };
        });
    });

    return {
        resourceName:   resource.name,
        appName:        this.getAppModuleName(prefix, appName),
        serviceName:    this.pancakes.utils.getCamelCase(resource.name + '.service'),
        modelName:      this.pancakes.utils.getPascalCase(resource.name),
        methods:        JSON.stringify(methods)
    };
}
903588
@Override
    public void visit(SingleMemberAnnotationExpr anno, ControllerModel controller) {

        //org.wisdom.api.annotations.Path
        if(anno.getName().getName().equals(ANNOTATION_PATH)){
            controller.setBasePath(asString(anno.getMemberValue()));
        }
    }
1189909
function constructor(models, options) {
      if (!Array.isArray(models)) {
        options = models;
        models = [];
      }

      options = options || {};

      //
      // Set the database name if it was provided in the options.
      //
      if (options.url) this.url = options.url;
      if (options.database) this.database = options.database;

      //
      // Define restricted non-enumerated properties.
      //
      predefine(this, fossa);

      //
      // Call original Backbone Model constructor.
      //
      backbone.Collection.call(this, models, options);
    }
617347
public void createControlAdapter()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.entry(tc, "createControlAdapter");
    controlAdapter = new ForeignBus(messageProcessor, this);
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.exit(tc, "createControlAdapter", controlAdapter);
  }
63604
function initModelUpdate (args) {
    var controller = this
    var model = this.model
    // if model does not have id column then cannot use default controller
    if (!model.columnName('id') || !model.columnName('parentId')) {
        return
    }
    // get accountId column
    var accountIdColumn = model.columnName('accountId') 
    // set role to authenticated if model requires account id
    var role = args.defaultRole || (accountIdColumn && model.columns[accountIdColumn].null === false ? 'authenticated' : 'all')
    // index inputs
    var input = {
        // get current revision of instance
        current: 'query.current',
        // get record even if deleted
        deleted: 'query.deleted',
        // ignore conflicts
        force: 'query.force',
        // instance id
        id: 'params.id',
        // merge update data into existing data
        merge: 'query.merge',
        // input data includes meta columns
        meta: 'query.meta',
    }
    // instance data is in body under model name
    input[model.name] = 'body.'+model.name
    // create path for PUT for API requests
    if (!this.paths['/:id']) {
        this.paths['/:id'] = {}
    }
    // create path for POST for form requests
    if (!this.paths['/:id/update']) {
        this.paths['/:id/update'] = {}
    }
    // add handler for PUT /:id and POST /:id/update
    // to update instance
    this.paths['/:id'].put = this.paths['/:id/update'].post = [
        {
            before: function (args) {
                // load model
                return loadRecordForUpdate(controller, args)
            },

            input: input,
            method: function (args) {
                // perform update
                return update(controller, args)
            },
            methodName: 'update',
            role: role,
            template: 'instance',
        },
    ]
}
117915
function __bindController (newController, sessionExpiration) {
    if (controller && typeof(controller.shutdown) === 'function') {
        controller.shutdown();
    }
    controller = newController;
    if (typeof(controller.clientInit) === 'function') {
        controller.clientInit(sessionExpiration);
    }
}
503500
@Override
	protected RequestMapping parseRequestMapping(MethodDoc methodDoc) {
		ClassDoc controllerClass = methodDoc.containingClass();
		RequestMapping baseMapping = null;
		boolean controllerCustomizedMapping = false;
		boolean actionCustomizedMapping = false;
		Tag[] tags = controllerClass.tags(WRAPITaglet.NAME);
		if (tags.length > 0) {
			baseMapping = this.parseRequestMapping(tags[0]);
		}

		if (baseMapping == null) {
			AnnotationDesc[] baseAnnotations = controllerClass.annotations();
			baseMapping = this.parseRequestMapping(baseAnnotations);
			controllerCustomizedMapping = false;
		} else {
			controllerCustomizedMapping = true;
		}

		RequestMapping mapping = null;
		Tag[] methodTags = methodDoc.tags(WRAPITaglet.NAME);
		if (methodTags.length > 0) {
			mapping = this.parseRequestMapping(methodTags[0]);
		}
		if (mapping == null) {
			AnnotationDesc[] annotations = methodDoc.annotations();
			mapping = this.parseRequestMapping(annotations);
			actionCustomizedMapping = false;
		} else {
			actionCustomizedMapping = true;
		}
		RequestMapping result;
		if (baseMapping == null) {
			result = mapping;
		} else if (mapping == null) {
			result = baseMapping;
		} else {
			if(!actionCustomizedMapping || controllerCustomizedMapping) {
				mapping.setUrl(net.winroad.wrdoclet.utils.Util.urlConcat(
						baseMapping.getUrl(), mapping.getUrl()));
			}
			if (baseMapping.getMethodType() != null) {
				if (mapping.getMethodType() != null) {
					mapping.setMethodType(baseMapping.getMethodType() + ","
							+ mapping.getMethodType());
				} else {
					mapping.setMethodType(baseMapping.getMethodType());
				}
			}
			result = mapping;
		}
		if (result != null) {
			result.setTooltip(methodDoc.containingClass().simpleTypeName());
			result.setContainerName(methodDoc.containingClass()
					.simpleTypeName());
		}
		return result;
	}
665914
function createCrudState (appname, masterSpec, moduleName, state, parentStateName, moduleUrl, agents) {
  var controllerPath = path.join(appname, 'generated', 'crud', parentStateName, 'controllers'),
    partialPath = path.join(appname, 'generated', 'partials', 'crud', parentStateName),
    crudType

  if (moduleName == 'POST' || moduleName == 'PUT') {
    crudType = 'postPut'
  }
  if (moduleName == 'FIND') {
    crudType = 'find'
  }
  if (moduleName == 'GET' || moduleName == 'DELETE') {
    crudType = 'get'
  }

  var specModel = {
    parentStateName: parentStateName,
    moduleName: moduleName,
    state: state,
    agents: agents,
    agentSpec: masterSpec.agents,
    crudAgent: crudAgent
  }
  var crudAgent = getUnrenderedTemplateContents(path.join('generated', 'crud', 'crudAgents.js'))
  var contents = getUnrenderedTemplateContents(path.join('generated', 'crud', crudType + 'Controller.js'))
  var controllerContents = mergeTemplateAndModel(contents, specModel)
  var agentControllerContents = mergeTemplateAndModel(crudAgent, specModel)

  createTemplate(appname, path.join('generated', 'crud', 'crudController.js'), {
    parentStateName: parentStateName,
    moduleName: moduleName,
    state: state,
    agents: agents,
    agentSpec: masterSpec.agents,
    crudControllerContents: controllerContents
  })

  var oldControllerPath = path.join(appname, 'generated', 'crud', 'crudController.js'),
    newControllerPath = path.join(controllerPath, moduleName + '.js')
  fs.renameSync(oldControllerPath, newControllerPath)

  if (agents.length) {
    createTemplate(appname, path.join('generated', 'crud', 'crudAgentController.js'), {
      parentStateName: parentStateName,
      moduleName: moduleName,
      state: state,
      agents: agents,
      agentSpec: masterSpec.agents,
      crudControllerContents: agentControllerContents
    })

    var oldControllerPath = path.join(appname, 'generated', 'crud', 'crudAgentController.js'),
      newControllerPath = path.join(controllerPath, parentStateName + 'AgentController.js')
    fs.renameSync(oldControllerPath, newControllerPath)
  }

  createTemplate(appname, path.join('generated', 'crud', crudType + '.html'), {
    moduleName: moduleName,
    parentStateName: parentStateName,
    state: state,
    moduleUrl: moduleUrl,
    agents: agents,
    agentSpec: masterSpec.agents // bringing the spec along for the ride for now
  })

  var oldHtmlPath = path.join(appname, 'generated', 'crud', crudType + '.html'),
    newHtmlPath = path.join(partialPath, moduleName + '.html')
  fs.renameSync(oldHtmlPath, newHtmlPath)
}
1366254
static function getController($module_name,$controller_name,$request,$view) {
        static $ctrls = NULL;
        $module_name  = strtolower($module_name);
        $controller_name = strtolower($controller_name);
        if (!$ctrls[$module_name][$controller_name]) {
            $controller = ucfirst($controller_name) . 'Controller';
            $controller_class = '\\' . self::getName() . '\\Controller\\' . ucfirst($module_name) . '\\' . $controller;
            if (!class_exists($controller_class)) {
                throw new Controller\NoControllerException;
            }
            $c = new $controller_class($request,$view);
            $ctrls[$module_name][$controller_name] = $c;
        }
        return $ctrls[$module_name][$controller_name];
    }
94574
static void populateResponse(final ModelNode response, final ServiceController<?> serviceController) {
        response.set(serviceController.getState().toString());
    }
770393
function initModelList (args) {
    var controller = this
    var model = this.model
    // make sure args is object
    args = requireValidOptionalObject(args)
    // make sure list is defined
    args.list = requireValidOptionalObject(args.list)
    // make sure query args are object
    var queryArgs = requireValidOptionalObject(args.list.query)
    // create title from name
    var title = model.title+' Records'
    // create new form instance configured to submit from list page
    if (controller.form && _.get(args, 'list.form') !== false) {
        var form = controller.form.newInstance({
            action: './?redirect=./',
        })
    }
    // get role
    var role = args.defaultRole || 'all'
    // build fields for table view
    this.fields = buildFields(model, args.list && args.list.fields)
    // index inputs
    var input = {
        // included deleted records
        deleted: 'query.deleted',
        // limit - overrides value in query if any
        limit: 'query.limit',
        // offset - overrides value in query if any
        offset: 'query.offset',
        // column to sort by
        orderColumn: 'query.orderColumn',
        // direction to sort in
        orderDirection: 'query.orderDirection',
        // free-form search string
        search: 'query.search',
        // list of columns to select
        select: 'query.select',
        // json encoded where arguments
        where: 'query.where',
    }
    // if model has an original id column then add to query options
    if (model.columnName('originalId')) {
        input.originalId = 'query.originalId'
    }
    // add extra columns as query param options
    _.each(model.extraColumns, (spec, name) => {
        // only add column if it has index
        if (!spec.index && !spec.unique) {
            return
        }
        // do not overwrite core inputs
        if (input[name]) {
            return
        }
        // add column to inputs
        input[name] = 'query.'+name
    })
    // links to display at top of page
    var links
    // use links from list view
    if (Array.isArray(args.list.links)) {
        links = args.list.links
    }
    // use global controller links
    else if (Array.isArray(args.links)) {
        links = args.links
    }
    // set default links
    else {
        links = [
            {href: './new', title: 'Create New'},
        ]
    }
    // create path if it does not exist
    if (!this.paths['/']) {
        this.paths['/'] = {}
    }
    // add list handler for GET on /
    this.paths['/'].get = [
        {
            before: function (args) {
                // load records
                return beforeList(controller, args, _.cloneDeep(controller.fields), title, form, links, queryArgs)
            },
            input: input,
            method: function (args) {
                return args.json
                    ? _.pick(args, ['records', 'result'])
                    : _.pick(args, ['clear', 'fields', 'form', 'links', 'pager', 'query', 'records', 'result', 'title'])
            },
            methodName: 'list',
            role: role,
        },
    ]
}