// NewWorkItemTypeGroupsController creates a work_item_type_groups controller.
348597
func NewWorkItemTypeGroupsController(service *goa.Service, db application.DB) *WorkItemTypeGroupsController {
	return &WorkItemTypeGroupsController{
		Controller: service.NewController("WorkItemTypeGroupsController"),
		db:         db,
	}
}
1353613
func (dsc *DaemonSetsController) processNextWorkItem() bool {
	dsKey, quit := dsc.queue.Get()
	if quit {
		return false
	}
	defer dsc.queue.Done(dsKey)

	err := dsc.syncHandler(dsKey.(string))
	if err == nil {
		dsc.queue.Forget(dsKey)
		return true
	}

	utilruntime.HandleError(fmt.Errorf("%v failed with : %v", dsKey, err))
	dsc.queue.AddRateLimited(dsKey)

	return true
}
102103
func NewWorkItemLinkRepository(db *gorm.DB) *GormWorkItemLinkRepository {
	return &GormWorkItemLinkRepository{
		db:                   db,
		workItemRepo:         workitem.NewWorkItemRepository(db),
		workItemTypeRepo:     workitem.NewWorkItemTypeRepository(db),
		workItemLinkTypeRepo: NewWorkItemLinkTypeRepository(db),
		revisionRepo:         NewRevisionRepository(db),
	}
}
535357
func (ssc *StatefulSetController) processNextWorkItem() bool {
	key, quit := ssc.queue.Get()
	if quit {
		return false
	}
	defer ssc.queue.Done(key)
	if err := ssc.sync(key.(string)); err != nil {
		utilruntime.HandleError(fmt.Errorf("Error syncing StatefulSet %v, requeuing: %v", key.(string), err))
		ssc.queue.AddRateLimited(key)
	} else {
		ssc.queue.Forget(key)
	}
	return true
}
216577
func (c *WorkItemTypeGroupController) Show(ctx *app.ShowWorkItemTypeGroupContext) error {
	var typeGroup *workitem.WorkItemTypeGroup
	var err error
	err = application.Transactional(c.db, func(appl application.Application) error {
		typeGroup, err = appl.WorkItemTypeGroups().Load(ctx, ctx.GroupID)
		if err != nil {
			return errs.WithStack(err)
		}
		return nil
	})
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, err)
	}
	return ctx.OK(&app.WorkItemTypeGroupSingle{
		Data: ConvertTypeGroup(ctx.Request, *typeGroup),
	})
}
1228686
func NewPaperEnabledUsersGroupAdditionType(Description string) *PaperEnabledUsersGroupAdditionType {
	s := new(PaperEnabledUsersGroupAdditionType)
	s.Description = Description
	return s
}
81276
func NewGroupAddExternalIdType(Description string) *GroupAddExternalIdType {
	s := new(GroupAddExternalIdType)
	s.Description = Description
	return s
}
742697
func NewNotifyingWorkitemsController(service *goa.Service, db application.DB, notificationChannel notification.Channel, config WorkItemControllerConfig) *WorkitemsController {
	n := notificationChannel
	if n == nil {
		n = &notification.DevNullChannel{}
	}
	return &WorkitemsController{
		Controller:   service.NewController("WorkitemController"),
		db:           db,
		notification: n,
		config:       config}
}
481123
func (r *GormWorkItemTypeRepository) Load(ctx context.Context, id uuid.UUID) (*WorkItemType, error) {
	defer goa.MeasureSince([]string{"goa", "db", "workitemtype", "load"}, time.Now())
	log.Debug(ctx, map[string]interface{}{
		"wit_id": id,
	}, "Loading work item type")
	res, ok := cache.Get(id)
	if !ok {
		log.Info(ctx, map[string]interface{}{
			"wit_id": id,
		}, "Work item type doesn't exist in the cache. Loading from DB...")
		res = WorkItemType{}

		db := r.db.Model(&res).Where("id=?", id).First(&res)
		if db.RecordNotFound() {
			log.Error(ctx, map[string]interface{}{
				"wit_id": id,
			}, "work item type not found")
			return nil, errors.NewNotFoundError("work item type", id.String())
		}
		if err := db.Error; err != nil {
			return nil, errors.NewInternalError(ctx, err)
		}
		childTypes, err := r.loadChildTypeList(ctx, res.ID)
		if err != nil {
			return nil, errs.Wrapf(err, `failed to load child types for WIT "%s" (%s)`, res.Name, res.ID)
		}
		res.ChildTypeIDs = childTypes
		cache.Put(res)
	}
	return &res, nil
}
769619
func NewGroupMovedType(Description string) *GroupMovedType {
	s := new(GroupMovedType)
	s.Description = Description
	return s
}
87047
func ConvertWorkItemStorageToModel(wiType *WorkItemType, wi *WorkItemStorage) (*WorkItem, error) {
	result, err := wiType.ConvertWorkItemStorageToModel(*wi)
	if err != nil {
		return nil, errors.NewConversionError(err.Error())
	}
	if _, ok := wiType.Fields[SystemCreatedAt]; ok {
		result.Fields[SystemCreatedAt] = wi.CreatedAt
	}
	if _, ok := wiType.Fields[SystemUpdatedAt]; ok {
		result.Fields[SystemUpdatedAt] = wi.UpdatedAt
	}
	if _, ok := wiType.Fields[SystemOrder]; ok {
		result.Fields[SystemOrder] = wi.ExecutionOrder
	}
	if _, ok := wiType.Fields[SystemNumber]; ok {
		result.Fields[SystemNumber] = wi.Number
	}
	return result, nil

}
1255068
func NewRetryStrategyWorker(config WorkerConfig) (worker.Worker, error) {
	if err := config.Validate(); err != nil {
		return nil, errors.Trace(err)
	}
	w, err := watcher.NewNotifyWorker(watcher.NotifyConfig{
		Handler: retryStrategyHandler{config},
	})
	if err != nil {
		return nil, errors.Trace(err)
	}
	return &RetryStrategyWorker{w, config.RetryStrategy}, nil
}
865517
func NewWorkItemLabelsController(service *goa.Service, db application.DB, config WorkItemLabelsControllerConfiguration) *WorkItemLabelsController {
	return &WorkItemLabelsController{
		Controller: service.NewController("WorkItemLabelsController"),
		db:         db,
		config:     config,
	}
}
869164
func (r Account_Shipment_Item) GetShipmentItemType() (resp datatypes.Account_Shipment_Item_Type, err error) {
	err = r.Session.DoRequest("SoftLayer_Account_Shipment_Item", "getShipmentItemType", nil, &r.Options, &resp)
	return
}
137910
func NewWorkitemtypeController(service *goa.Service, db application.DB, config workItemTypeControllerConfiguration) *WorkitemtypeController {
	return &WorkitemtypeController{
		Controller: service.NewController("WorkitemtypeController"),
		db:         db,
		config:     config,
	}
}
977854
func (r *GormWorkItemTypeRepository) ListPlannerItemTypes(ctx context.Context, spaceTemplateID uuid.UUID) ([]WorkItemType, error) {
	defer goa.MeasureSince([]string{"goa", "db", "workitemtype", "listPlannerItemTypes"}, time.Now())

	// check space template exists
	if err := spacetemplate.NewRepository(r.db).CheckExists(ctx, spaceTemplateID); err != nil {
		return nil, errors.NewNotFoundError("space template", spaceTemplateID.String())
	}

	var wits []WorkItemType
	db := r.db.Select("id").Where("space_template_id = ? AND path::text LIKE '"+path.ConvertToLtree(SystemPlannerItem)+".%'", spaceTemplateID.String()).Order("created_at")
	if err := db.Find(&wits).Error; err != nil {
		log.Error(ctx, map[string]interface{}{
			"space_template_id": spaceTemplateID,
			"err":               err,
		}, "unable to list the work item types that derive off of planner item type")
		return nil, errs.WithStack(err)
	}
	for i, wit := range wits {
		childTypes, err := r.loadChildTypeList(ctx, wit.ID)
		if err != nil {
			return nil, errs.Wrapf(err, `failed to load child types for WIT "%s" (%s)`, wit.Name, wit.ID)
		}
		wits[i].ChildTypeIDs = childTypes
	}
	return wits, nil

}
1353054
func ParseSortWorkItemsBy(s *string) (SortWorkItemsBy, error) {
	if s == nil {
		// this is the default case
		// which returns workitems with highest execution order
		return SortWorkItemsByDefault, nil
	}

	var sort SortWorkItemsBy
	switch *s {
	case "execution":
		sort = SortWorkItemsByExecutionAsc
	case "-execution":
		sort = SortWorkItemsByExecutionDesc
	case "created":
		sort = SortWorkItemsByCreatedAtAsc
	case "-created":
		sort = SortWorkItemsByCreatedAtDesc
	case "updated":
		sort = SortWorkItemsByUpdatedAtAsc
	case "-updated":
		sort = SortWorkItemsByUpdatedAtDesc
	default:
		return SortWorkItemsBy(""), errors.NewBadParameterError("sort", *s)
	}
	return sort, nil
}