Exemple #1
0
class ComplexNode(Node):
    p1 = Param()
    p2 = Param()

    def param_touched(self, param_name):
        if param_name == 'p1':
            self.p2.touch()

    child1 = Child(MyNode)
    child2 = Child(MyNode)
Exemple #2
0
class HumanTask(AbstractTask):
    with param_group('Assigned'):
        candidats = ComputedParam().ui(editor='choices_for', editor_options={'target_param':'user'})
        user = CaseParam().ui(editor='node_ref', editor_options={'root_name':'resources'})
        
    _status_manager = Child(HumanTaskStatus).affects(AbstractTask.status)
    
    def _configure(self):
        super(HumanTask, self)._configure()
        self.candidats.add_source(self.parent().user_groups)
    
    def compute(self, param_name):
        if param_name == 'candidats':
            if not self.candidats.has_source():
                self.candidats.set([])
            else:
                uids = self.candidats.get_from_sources()
                if uids is None:
                    self.candidats.set([])
                else:
                    nodes = [ self.flow().get(uid) for uid in uids ]
                    groups = [ n for n in nodes if n.has_param('users') ]
                    users = [ n.uid() for n in nodes if n.has_param('login') ]
                    [ users.extend(group.users.get() or []) for group in groups ]
                    self.candidats.set(sorted(set(users)))
        else:
            super(HumanTask, self).compute(param_name)
Exemple #3
0
class TaskGroup(NamedNode):
    ICON_NAME = 'action'

    with param_group('Tasks'):
        tasks_statuses = Param({}, sources_as_dict=True).ui(editor='status_sumary')
        tasks_progresses = Param({}, sources_as_dict=True)
        status = ComputedParam()
        progress = ComputedParam().ui(editor='percent')

    _status_manager = Child(TaskGroupStatus) # NB: this is a status summary, it does not affect a param 
    notes = Child(NoteThread)

    def _configure(self):
        super(TaskGroup, self)._configure()
        for _, child in self.iterchildren():
            if child.has_param('status'):
                self.tasks_statuses.add_source(child.status)
            if child.has_param('progress'):
                self.tasks_progresses.add_source(child.progress)

    def param_touched(self, param_name):
        if param_name == 'tasks_progresses':
            self.progress.touch()
            
        elif param_name == 'progress':
            self.status.touch()
            
    def compute(self, param_name):
        if param_name == 'progress':
            self.progress.set(
                self._status_manager.get_average_progress(
                    (self.tasks_progresses.get() or {}).values()
                )
            )
                
        if param_name == 'status':
            self.status.set(
                self._status_manager.get_status(
                    self.progress.get()
                )
            )
Exemple #4
0
class HumanTaskStatus(StatusManager):
    NYS = Child(StatusValue).set_progress(0)
    
    INV = Child(StatusValue).after(NYS).set_progress(10)
    WIP = Child(StatusValue).after(INV).set_progress(50)
    RVW = Child(StatusValue).after(WIP).set_progress(60)
    RTK = Child(StatusValue).after(RVW).before(RVW).set_progress(80)
    APP = Child(StatusValue).after(RVW).set_progress(100)
    
    OOP = Child(StatusValue).set_progress(100)
Exemple #5
0
class NamedNode(Node):
    with param_group('_Naming', group_index=1000):
        _naming = Param()

    _namer = Child(NamingNode)

    def set_namer_config(self, **config):
        self._namer.config.set(config)
    
    def add_namer_config(self, **config):
        cfg = self._namer.config.get() or {}
        cfg.update(config)
        self._namer.config.set(cfg)
        
    def set_namer_from_id(self, key=None):
        key = key or self.__class__.__name__
        self._namer.config.set({key:self.node_id})
Exemple #6
0
class TaskGroupStatus(StatusManager):
    NYS = Child(StatusValue).set_progress(0)
    INV = Child(StatusValue).after(NYS).set_progress(1)
    WIP = Child(StatusValue).after(INV).set_progress(11)
    FIN = Child(StatusValue).after(WIP).set_progress(100)
Exemple #7
0
class BatchTask(AbstractTask):

    _status_manager = Child(BatchTaskStatus).affects(AbstractTask.status)
Exemple #8
0
class BatchTaskStatus(StatusManager):
    WAIT_INPUT = Child(StatusValue).set_progress(0)
    IN_PROGRESS = Child(StatusValue).after(WAIT_INPUT).set_progress(50)
    DONE = Child(StatusValue).after(IN_PROGRESS).after(WAIT_INPUT).set_progress(100)
Exemple #9
0
class MyComposedNode(Node):
    p1 = CaseParam()

    my_child = Child(MyNode)
Exemple #10
0
class CasedNode(Node):
    node_param = Param()
    node_case_param = CaseParam(default='Case Param Default')
    
    c1 = Child(ChildNode).configure('Param in c1')
    c2 = Child(ChildNode).configure('Param in c2')