projectal.entities.task_template
1from projectal.entity import Entity 2from projectal.linkers import * 3 4 5class TaskTemplate( 6 Entity, 7 ResourceLinker, 8 SkillLinker, 9 FileLinker, 10 StaffLinker, 11 RebateLinker, 12 NoteLinker, 13 TagLinker, 14): 15 """ 16 Implementation of the 17 [Task Template](https://projectal.com/docs/latest/#tag/Task-Template) API. 18 """ 19 20 _path = "template/task" 21 _name = "task_template" 22 _links = [ 23 ResourceLinker, 24 SkillLinker, 25 FileLinker, 26 StaffLinker, 27 RebateLinker, 28 NoteLinker, 29 TagLinker, 30 ] 31 32 def clone(self, holder, entity): 33 url = "/api/template/task/clone?holder={}&reference={}".format( 34 holder["uuId"], self["uuId"] 35 ) 36 response = api.post(url, entity) 37 return response["jobClue"]["uuId"] 38 39 @classmethod 40 def create( 41 cls, 42 holder, 43 entity, 44 batch_linking=True, 45 disable_system_features=True, 46 enable_system_features_on_exit=True, 47 ): 48 """Create a Task Template 49 50 `holder`: `uuId` of the owner 51 52 `entity`: The fields of the entity to be created 53 """ 54 holder = holder["uuId"] if isinstance(holder, dict) else holder 55 params = "?holder=" + holder 56 return super().create( 57 entity, 58 params, 59 batch_linking, 60 disable_system_features, 61 enable_system_features_on_exit, 62 ) 63 64 @classmethod 65 def list(cls, expand=False, links=None): 66 """Return a list of all entity UUIDs of this type. 67 68 You may pass in `expand=True` to get full Entity objects 69 instead, but be aware this may be very slow if you have 70 thousands of objects. 71 72 If you are expanding the objects, you may further expand 73 the results with `links`. 74 """ 75 76 payload = { 77 "name": "List all entities of type {}".format(cls._name.upper()), 78 "type": "msql", 79 "start": 0, 80 "limit": -1, 81 "select": [["PROJECT_TEMPLATE.{}.uuId".format(cls._name.upper())]], 82 } 83 ids = api.query(payload) 84 ids = [id_[0] for id_ in ids] 85 if ids: 86 return cls.get(ids, links=links) if expand else ids 87 return [] 88 89 @classmethod 90 def link_predecessor_task(cls, task, predecessor_task): 91 return cls.__plan(task, predecessor_task, "add") 92 93 @classmethod 94 def relink_predecessor_task(cls, task, predecessor_task): 95 return cls.__plan(task, predecessor_task, "update") 96 97 @classmethod 98 def unlink_predecessor_task(cls, task, predecessor_task): 99 return cls.__plan(task, predecessor_task, "delete") 100 101 @classmethod 102 def __plan(cls, from_task, to_task, operation): 103 url = "/api/template/task/plan/task/{}".format(operation) 104 payload = {"uuId": from_task["uuId"], "taskList": [to_task]} 105 api.post(url, payload=payload) 106 return True
class
TaskTemplate(projectal.entity.Entity, projectal.linkers.ResourceLinker, projectal.linkers.SkillLinker, projectal.linkers.FileLinker, projectal.linkers.StaffLinker, projectal.linkers.RebateLinker, projectal.linkers.NoteLinker, projectal.linkers.TagLinker):
6class TaskTemplate( 7 Entity, 8 ResourceLinker, 9 SkillLinker, 10 FileLinker, 11 StaffLinker, 12 RebateLinker, 13 NoteLinker, 14 TagLinker, 15): 16 """ 17 Implementation of the 18 [Task Template](https://projectal.com/docs/latest/#tag/Task-Template) API. 19 """ 20 21 _path = "template/task" 22 _name = "task_template" 23 _links = [ 24 ResourceLinker, 25 SkillLinker, 26 FileLinker, 27 StaffLinker, 28 RebateLinker, 29 NoteLinker, 30 TagLinker, 31 ] 32 33 def clone(self, holder, entity): 34 url = "/api/template/task/clone?holder={}&reference={}".format( 35 holder["uuId"], self["uuId"] 36 ) 37 response = api.post(url, entity) 38 return response["jobClue"]["uuId"] 39 40 @classmethod 41 def create( 42 cls, 43 holder, 44 entity, 45 batch_linking=True, 46 disable_system_features=True, 47 enable_system_features_on_exit=True, 48 ): 49 """Create a Task Template 50 51 `holder`: `uuId` of the owner 52 53 `entity`: The fields of the entity to be created 54 """ 55 holder = holder["uuId"] if isinstance(holder, dict) else holder 56 params = "?holder=" + holder 57 return super().create( 58 entity, 59 params, 60 batch_linking, 61 disable_system_features, 62 enable_system_features_on_exit, 63 ) 64 65 @classmethod 66 def list(cls, expand=False, links=None): 67 """Return a list of all entity UUIDs of this type. 68 69 You may pass in `expand=True` to get full Entity objects 70 instead, but be aware this may be very slow if you have 71 thousands of objects. 72 73 If you are expanding the objects, you may further expand 74 the results with `links`. 75 """ 76 77 payload = { 78 "name": "List all entities of type {}".format(cls._name.upper()), 79 "type": "msql", 80 "start": 0, 81 "limit": -1, 82 "select": [["PROJECT_TEMPLATE.{}.uuId".format(cls._name.upper())]], 83 } 84 ids = api.query(payload) 85 ids = [id_[0] for id_ in ids] 86 if ids: 87 return cls.get(ids, links=links) if expand else ids 88 return [] 89 90 @classmethod 91 def link_predecessor_task(cls, task, predecessor_task): 92 return cls.__plan(task, predecessor_task, "add") 93 94 @classmethod 95 def relink_predecessor_task(cls, task, predecessor_task): 96 return cls.__plan(task, predecessor_task, "update") 97 98 @classmethod 99 def unlink_predecessor_task(cls, task, predecessor_task): 100 return cls.__plan(task, predecessor_task, "delete") 101 102 @classmethod 103 def __plan(cls, from_task, to_task, operation): 104 url = "/api/template/task/plan/task/{}".format(operation) 105 payload = {"uuId": from_task["uuId"], "taskList": [to_task]} 106 api.post(url, payload=payload) 107 return True
Implementation of the Task Template API.
def
clone(self, holder, entity):
33 def clone(self, holder, entity): 34 url = "/api/template/task/clone?holder={}&reference={}".format( 35 holder["uuId"], self["uuId"] 36 ) 37 response = api.post(url, entity) 38 return response["jobClue"]["uuId"]
Clones an entity and returns its uuId
.
Each entity has its own set of required values when cloning. Check the API documentation of that entity for details.
@classmethod
def
create( cls, holder, entity, batch_linking=True, disable_system_features=True, enable_system_features_on_exit=True):
40 @classmethod 41 def create( 42 cls, 43 holder, 44 entity, 45 batch_linking=True, 46 disable_system_features=True, 47 enable_system_features_on_exit=True, 48 ): 49 """Create a Task Template 50 51 `holder`: `uuId` of the owner 52 53 `entity`: The fields of the entity to be created 54 """ 55 holder = holder["uuId"] if isinstance(holder, dict) else holder 56 params = "?holder=" + holder 57 return super().create( 58 entity, 59 params, 60 batch_linking, 61 disable_system_features, 62 enable_system_features_on_exit, 63 )
Create a Task Template
holder
: uuId
of the owner
entity
: The fields of the entity to be created
@classmethod
def
list(cls, expand=False, links=None):
65 @classmethod 66 def list(cls, expand=False, links=None): 67 """Return a list of all entity UUIDs of this type. 68 69 You may pass in `expand=True` to get full Entity objects 70 instead, but be aware this may be very slow if you have 71 thousands of objects. 72 73 If you are expanding the objects, you may further expand 74 the results with `links`. 75 """ 76 77 payload = { 78 "name": "List all entities of type {}".format(cls._name.upper()), 79 "type": "msql", 80 "start": 0, 81 "limit": -1, 82 "select": [["PROJECT_TEMPLATE.{}.uuId".format(cls._name.upper())]], 83 } 84 ids = api.query(payload) 85 ids = [id_[0] for id_ in ids] 86 if ids: 87 return cls.get(ids, links=links) if expand else ids 88 return []
Return a list of all entity UUIDs of this type.
You may pass in expand=True
to get full Entity objects
instead, but be aware this may be very slow if you have
thousands of objects.
If you are expanding the objects, you may further expand
the results with links
.