def create_if_not_exists(self, queue_name: str, user=ProcessDefinitionDefault.USER) -> None: """Create Tenant if not exists.""" gateway = launch_gateway() gateway.entry_point.createTenant(self.name, self.description, queue_name)
def get_datasource_info(self, name) -> Dict: """Get datasource info from java gateway, contains datasource id, type, name.""" if self._datasource: return self._datasource else: gateway = launch_gateway() self._datasource = gateway.entry_point.getDatasourceInfo(name) return self._datasource
def create_if_not_exists(self, **kwargs): """Create User if not exists.""" gateway = launch_gateway() gateway.entry_point.createUser( self.name, self.password, self.email, self.phone, self.tenant, self.queue, self.status, )
def get_process_definition_info(self, process_definition_name: str) -> Dict: """Get process definition info from java gateway, contains process definition id, name, code.""" if self._process_definition_info: return self._process_definition_info else: gateway = launch_gateway() self._process_definition_info = ( gateway.entry_point.getProcessDefinitionInfo( self.process_definition.user.name, self.process_definition.project.name, process_definition_name, )) return self._process_definition_info
def start(self) -> None: """Create and start ProcessDefinition instance. which post to `start-process-instance` to java gateway """ gateway = launch_gateway() gateway.entry_point.execProcessInstance( self._user, self._project, self.name, "", self.worker_group, 24 * 3600, )
def gen_code_and_version(self) -> Tuple: """ Generate task code and version from java gateway. If task name do not exists in process definition before, if will generate new code and version id equal to 0 by java gateway, otherwise if will return the exists code and version. """ # TODO get code from specific project process definition and task name gateway = launch_gateway() result = gateway.entry_point.getCodeAndVersion( self.process_definition._project, self.name) # result = gateway.entry_point.genTaskCodeList(DefaultTaskCodeNum.DEFAULT) # gateway_result_checker(result) return result.get("code"), result.get("version")
def submit(self) -> int: """Submit ProcessDefinition instance to java gateway.""" self._ensure_side_model_exists() gateway = launch_gateway() self._process_definition_code = gateway.entry_point.createOrUpdateProcessDefinition( self._user, self._project, self.name, str(self.description) if self.description else "", str(self.param) if self.param else None, json.dumps(self.schedule_json) if self.schedule_json else None, json.dumps(self.task_location), self.timeout, self.worker_group, self._tenant, # TODO add serialization function json.dumps(self.task_relation_json), json.dumps(self.task_definition_json), None, ) return self._process_definition_code
def create_if_not_exists(self, user=ProcessDefinitionDefault.USER) -> None: """Create Queue if not exists.""" gateway = launch_gateway() # Here we set Queue.name and Queue.queueName same as self.name result = gateway.entry_point.createProject(user, self.name, self.name) gateway_result_checker(result, None)
def create_if_not_exists(self, user=ProcessDefinitionDefault.USER) -> None: """Create Project if not exists.""" gateway = launch_gateway() gateway.entry_point.createProject(user, self.name, self.description)