Esempio n. 1
0
 def get_hosted_workflow_version(cls, hosting_service: Resource, uuid, version) -> List[WorkflowVersion]:
     # TODO: replace WorkflowRegistry with a more general Entity
     try:
         return cls.query\
             .join(WorkflowRegistry, cls.hosting_service)\
             .join(Workflow, Workflow.id == cls.workflow_id)\
             .filter(WorkflowRegistry.uuid == lm_utils.uuid_param(hosting_service.uuid))\
             .filter(Workflow.uuid == lm_utils.uuid_param(uuid))\
             .filter(cls.version == version)\
             .order_by(WorkflowVersion.version.desc()).one()
     except NoResultFound as e:
         logger.debug(e)
         return None
     except Exception as e:
         raise lm_exceptions.LifeMonitorException(detail=str(e), stack=str(e))
Esempio n. 2
0
 def get_hosted_workflow_versions(
         cls, hosting_service: Resource) -> List[WorkflowVersion]:
     # TODO: replace WorkflowRegistry with a more general Entity
     return cls.query\
         .join(WorkflowRegistry, cls.hosting_service)\
         .filter(WorkflowRegistry.uuid == lm_utils.uuid_param(hosting_service.uuid))\
         .order_by(WorkflowVersion.version.desc()).all()
Esempio n. 3
0
 def find_by_uuid(cls, uuid) -> WorkflowRegistry:
     try:
         return cls.query.filter(
             WorkflowRegistry.uuid == lm_utils.uuid_param(uuid)).one()
     except NoResultFound as e:
         logger.debug(e)
         return None
     except Exception as e:
         raise lm_exceptions.LifeMonitorException(detail=str(e),
                                                  stack=str(e))
Esempio n. 4
0
 def get_user_workflow(cls, owner: User, uuid) -> Workflow:
     try:
         return cls.query\
             .join(Permission)\
             .filter(Permission.resource_id == cls.id, Permission.user_id == owner.id)\
             .filter(cls.uuid == lm_utils.uuid_param(uuid)).one()
     except NoResultFound as e:
         logger.debug(e)
         return None
     except Exception as e:
         raise lm_exceptions.LifeMonitorException(detail=str(e), stack=str(e))
Esempio n. 5
0
 def get_workflow(self, uuid_or_identifier) -> models.Workflow:
     try:
         w = next((
             w for w in self.registered_workflow_versions
             if w.workflow.uuid == lm_utils.uuid_param(uuid_or_identifier)),
                  None)
         return w.workflow if w is not None else None
     except ValueError:
         w = next((w for w in self.registered_workflow_versions
                   if w.workflow.external_id == uuid_or_identifier), None)
         return w.workflow if w is not None else None
     except Exception:
         if models.Workflow.find_by_uuid(uuid_or_identifier) is not None:
             raise lm_exceptions.NotAuthorizedException()
Esempio n. 6
0
 def find_by_uuid(cls, uuid):
     return cls.query.filter(cls.uuid == lm_utils.uuid_param(uuid)).first()