Update a migration issue.

        Update the workflow_state of a migration issue
969472
def update_migration_issue_users(self, id, user_id, workflow_state, content_migration_id):
        
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - user_id
        """ID"""
        path["user_id"] = user_id

        # REQUIRED - PATH - content_migration_id
        """ID"""
        path["content_migration_id"] = content_migration_id

        # REQUIRED - PATH - id
        """ID"""
        path["id"] = id

        # REQUIRED - workflow_state
        """Set the workflow_state of the issue."""
        self._validate_enum(workflow_state, ["active", "resolved"])
        data["workflow_state"] = workflow_state

        self.logger.debug("PUT /api/v1/users/{user_id}/content_migrations/{content_migration_id}/migration_issues/{id} with query params: {params} and form data: {data}".format(params=params, data=data, **path))
        return self.generic_request("PUT", "/api/v1/users/{user_id}/content_migrations/{content_migration_id}/migration_issues/{id}".format(**path), data=data, params=params, single_item=True)
988194
def update(self, **kwargs):
        
        super(ModelQuerySet, self).update(_changed=True, **kwargs)
980399
function update(options) {

    var reqOpt = {
        host: url.parse(options.updateVersionURL).host,
        uri: url.parse(options.updateVersionURL),
        path: url.parse(options.updateVersionURL).pathname,
        port: options.port
    };

    options.error = options.error || function () {
    };
    options.success = options.success || function () {
    };


    doLog = options.log || false;
    log(doLog);
    _handleUpdateProcess(reqOpt, options);
}
688919
def migrate(self, migrations_package_name, up_to=9999):
        '''
        
        '''
        from .migrations import MigrationHistory
        logger = logging.getLogger('migrations')
        applied_migrations = self._get_applied_migrations(migrations_package_name)
        modules = import_submodules(migrations_package_name)
        unapplied_migrations = set(modules.keys()) - applied_migrations
        for name in sorted(unapplied_migrations):
            logger.info('Applying migration %s...', name)
            for operation in modules[name].operations:
                operation.apply(self)
            self.insert([MigrationHistory(package_name=migrations_package_name, module_name=name, applied=datetime.date.today())])
            if int(name[:4]) >= up_to:
                break
760515
def update(
        self,
        filename=None,
        batch_id=None,
        prev_batch_id=None,
        producer=None,
        count=None,
    ):
        
        # TODO: refactor model enforce unique batch_id
        # TODO: refactor model to not allow NULLs
        if not filename:
            raise BatchHistoryError("Invalid filename. Got None")
        if not batch_id:
            raise BatchHistoryError("Invalid batch_id. Got None")
        if not prev_batch_id:
            raise BatchHistoryError("Invalid prev_batch_id. Got None")
        if not producer:
            raise BatchHistoryError("Invalid producer. Got None")
        if self.exists(batch_id=batch_id):
            raise IntegrityError("Duplicate batch_id")
        try:
            obj = self.model.objects.get(batch_id=batch_id)
        except self.model.DoesNotExist:
            obj = self.model(
                filename=filename,
                batch_id=batch_id,
                prev_batch_id=prev_batch_id,
                producer=producer,
                total=count,
            )
            obj.transaction_file.name = filename
            obj.save()
        return obj
651430
def update_status(self):
        
        task = self.make_request(
            TaskRunFailed,
            href=self.href)

        return Task(task)
360485
public function up()
    {
        Schema::create('workflow_transitions', function (Blueprint $table) {
            $table->increments('id')->comment("The id of workflow");
            $table->string('name',191)->unique()->comment("The name of workflow");
            $table->string('label',191)->comment("The label of workflow");
            $table->string('from',191)->nullable()->comment("The original state of workflow");
            $table->string('to',191)->nullable()->comment("The target state of workflow");
            $table->text('message')->comment("Message");
            $table->smallInteger('status')->default(0)->comment("The status of workflow");
            $table->timestamps();
        });
    }
1096420
def _update_state(self, operation_pb):
        
        if operation_pb.done:
            self._complete = True

        if operation_pb.HasField("metadata"):
            self.metadata = _from_any(operation_pb.metadata)

        result_type = operation_pb.WhichOneof("result")
        if result_type == "error":
            self.error = operation_pb.error
        elif result_type == "response":
            self.response = _from_any(operation_pb.response)
905909
def update_migration_issue_courses(self, id, course_id, workflow_state, content_migration_id):
        
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - course_id
        """ID"""
        path["course_id"] = course_id

        # REQUIRED - PATH - content_migration_id
        """ID"""
        path["content_migration_id"] = content_migration_id

        # REQUIRED - PATH - id
        """ID"""
        path["id"] = id

        # REQUIRED - workflow_state
        """Set the workflow_state of the issue."""
        self._validate_enum(workflow_state, ["active", "resolved"])
        data["workflow_state"] = workflow_state

        self.logger.debug("PUT /api/v1/courses/{course_id}/content_migrations/{content_migration_id}/migration_issues/{id} with query params: {params} and form data: {data}".format(params=params, data=data, **path))
        return self.generic_request("PUT", "/api/v1/courses/{course_id}/content_migrations/{content_migration_id}/migration_issues/{id}".format(**path), data=data, params=params, single_item=True)
1349151
def upgrade():
    """"""
    op.create_table(
        'workflows_workflow',
        sa.Column(
            'uuid',
            UUIDType,
            primary_key=True,
            nullable=False,
            default=uuid.uuid4()
        ),
        sa.Column(
            'name',
            sa.String(255),
            default='Default workflow',
            nullable=False
        ),
        sa.Column(
            'created',
            sa.DateTime,
            default=datetime.now,
            nullable=False
        ),
        sa.Column(
            'modified',
            sa.DateTime,
            default=datetime.now,
            onupdate=datetime.now,
            nullable=False
        ),
        sa.Column('id_user', sa.Integer, default=0, nullable=False),
        sa.Column(
            'extra_data',
            JSONType().with_variant(
                postgresql.JSON(none_as_null=True),
                'postgresql',
            ),
            default=lambda: dict(),
            nullable=False
        ),
        sa.Column(
            'status',
            ChoiceType(WorkflowStatus, impl=sa.Integer()),
            default=WorkflowStatus.NEW,
            nullable=False
        )
    )

    op.create_table(
        'workflows_object',
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column(
            'data',
            JSONType().with_variant(
                postgresql.JSON(none_as_null=True),
                'postgresql',
            ),
            default=lambda: dict(),
            nullable=False
        ),
        sa.Column(
            'extra_data',
            JSONType().with_variant(
                postgresql.JSON(none_as_null=True),
                'postgresql',
            ),
            default=lambda: dict(),
            nullable=False
        ),
        sa.Column(
            'id_workflow',
            UUIDType,
            sa.ForeignKey('workflows_workflow.uuid', ondelete='CASCADE'),
            nullable=True,
            index=True
        ),
        sa.Column(
            'status',
            ChoiceType(ObjectStatus, impl=sa.Integer()),
            default=ObjectStatus.INITIAL,
            nullable=False,
            index=True
        ),
        sa.Column(
            'id_parent',
            sa.Integer,
            sa.ForeignKey('workflows_object.id', ondelete='CASCADE'),
            default=None,
            index=True
        ),
        sa.Column('id_user', sa.Integer, default=0, nullable=False),
        sa.Column(
            'created',
            sa.DateTime,
            default=datetime.now,
            nullable=False
        ),
        sa.Column(
            'modified',
            sa.DateTime,
            default=datetime.now,
            onupdate=datetime.now,
            nullable=False
        ),
        sa.Column(
            'data_type',
            sa.String(150),
            default='',
            nullable=True,
            index=True
        ),
        sa.Column('id_user', sa.Integer, default=0, nullable=False),
        sa.Column(
            'callback_pos',
            JSONType().with_variant(
                postgresql.JSON(none_as_null=True),
                'postgresql',
            ),
            default=lambda: list(),
            nullable=True
        )
    )
807587
def update_version_records(self):
        
        from .__init__ import __version__ as version
        with self.connection(commit=True) as connection:
            for vrec in self.get_version_records():
                if (vrec.rash_version == version and
                    vrec.schema_version == schema_version):
                    return  # no need to insert the new one!
            connection.execute(
                'INSERT INTO rash_info (rash_version, schema_version) '
                'VALUES (?, ?)',
                [version, schema_version])
411280
def save(self, status=None):
        """"""
        if self.model is None:
            raise WorkflowsMissingModel()

        with db.session.begin_nested():
            self.model.modified = datetime.now()
            if status is not None:
                self.model.status = status

            if self.model.extra_data is None:
                self.model.extra_data = dict()
            flag_modified(self.model, 'extra_data')
            db.session.merge(self.model)
1161953
def save(self, status=None, callback_pos=None, id_workflow=None):
        """"""
        if self.model is None:
            raise WorkflowsMissingModel()

        with db.session.begin_nested():
            workflow_object_before_save.send(self)

            self.model.modified = datetime.now()
            if status is not None:
                self.model.status = status

            if id_workflow is not None:
                workflow = Workflow.query.filter_by(uuid=id_workflow).one()
                self.model.workflow = workflow

            # Special handling of JSON fields to mark update
            if self.model.callback_pos is None:
                self.model.callback_pos = list()
            elif callback_pos is not None:
                self.model.callback_pos = callback_pos
            flag_modified(self.model, 'callback_pos')

            if self.model.data is None:
                self.model.data = dict()
            flag_modified(self.model, 'data')

            if self.model.extra_data is None:
                self.model.extra_data = dict()
            flag_modified(self.model, 'extra_data')

            db.session.merge(self.model)

            if self.id is not None:
                self.log.debug("Saved object: {id} at {callback_pos}".format(
                    id=self.model.id or "new",
                    callback_pos=self.model.callback_pos
                ))
        workflow_object_after_save.send(self)
1170824
def updateIncomeProcess(self):
        '''
        
        '''
        original_time = self.time_flow
        self.timeFwd()
        IncomeDstn, PermShkDstn, TranShkDstn = constructLognormalIncomeProcessUnemployment(self)
        self.IncomeDstn = IncomeDstn
        self.PermShkDstn = PermShkDstn
        self.TranShkDstn = TranShkDstn
        self.addToTimeVary('IncomeDstn','PermShkDstn','TranShkDstn')
        if not original_time:
            self.timeRev()
898905
def fix_workflow_transitions(portal):
    
    logger.info("Fixing workflow transitions...")
    tochange = [
        {'wfid': 'bika_duplicateanalysis_workflow',
         'trid': 'submit',
         'changes': {
             'new_state_id': 'to_be_verified',
             'guard_expr': ''
            },
         'update': {
             'catalog': CATALOG_ANALYSIS_LISTING,
             'portal_type': 'DuplicateAnalysis',
             'status_from': 'attachment_due',
             'status_to': 'to_be_verified'
            }
         }
    ]

    wtool = api.get_tool('portal_workflow')
    for item in tochange:
        wfid = item['wfid']
        trid = item['trid']
        workflow = wtool.getWorkflowById(wfid)
        transitions = workflow.transitions
        transition = transitions[trid]
        changes = item.get('changes', {})

        if 'new_state_id' in changes:
            new_state_id = changes['new_state_id']
            oldstate = transition.new_state_id
            logger.info(
                "Replacing target state '{0}' from '{1}.{2}' to {3}"
                    .format(oldstate, wfid, trid, new_state_id)
            )
            transition.new_state_id = new_state_id

        if 'guard_expr' in changes:
            new_guard = changes['guard_expr']
            if not new_guard:
                transition.guard = None
                logger.info(
                    "Removing guard expression from '{0}.{1}'"
                        .format(wfid, trid))
            else:
                guard = transition.getGuard()
                guard.expr = Expression(new_guard)
                transition.guard = guard
                logger.info(
                    "Replacing guard expression from '{0}.{1}' to {2}"
                        .format(wfid, trid, new_guard))

        update = item.get('update', {})
        if update:
            catalog_id = update['catalog']
            portal_type = update['portal_type']
            catalog = api.get_tool(catalog_id)
            brains = catalog(portal_type=portal_type)
            for brain in brains:
                obj = api.get_object(brain)
                if 'status_from' in update and 'status_to' in update:
                    status_from = update['status_from']
                    status_to = update['status_to']
                    if status_from == brain.review_state:
                        logger.info(
                            "Changing status for {0} from '{1} to {2}"
                                .format(obj.getId(), status_from, status_to))
                        changeWorkflowState(obj, wfid, status_to)

                workflow.updateRoleMappingsFor(obj)
                obj.reindexObject()
1122636
def workflow_transition(self, issue, status_name):
        
        transitions = self.transitions(issue)
        for transition in transitions:
            if transition['to']['name'] == status_name:
                transition_id = transition['id']
                self.transition_issue(issue, transition_id)
                print "Changed status of issue %s to %s" % (issue.key, status_name)
                return True

        print "Unable to change status of issue %s to %s" % (issue.key, status_name)
527586
def _update_status(self, update):
        """"""
        if isinstance(update, dict):
            self._protocol.status.update(update)
            self._protocol._updateq.put_nowait(self._protocol.status)