1 ##############################################################################
2 # Copyright (c) 2018 Sawyer Bergeron, Parker Berberian, and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
11 from workflow.booking_workflow import *
12 from workflow.resource_bundle_workflow import *
13 from workflow.sw_bundle_workflow import *
14 from workflow.snapshot_workflow import *
15 from workflow.models import Workflow, Repository
20 logger = logging.getLogger(__name__)
22 class BookingMetaWorkflow(object):
27 class ResourceMetaWorkflow(object):
31 class ConfigMetaWorkflow(object):
35 class MetaRelation(object):
36 def __init__(self, *args, **kwargs):
37 self.color = "#cccccc"
45 'parent': self.parent,
46 'children': self.children,
50 class MetaStep(object):
51 #valid = 0 #0 is not checked, 1 is invalid, 2 is valid
57 def set_invalid(self, message, code=100):
59 self.message = message
61 def set_valid(self, message, code=200):
63 self.message = message
65 def __init__(self, *args, **kwargs):
66 self.short_title = "error"
70 self.id = uuid.uuid4()
74 'title': self.short_title,
75 'skip': self.skip_step,
77 'message': self.message,
81 return "metastep: " + str(self.short_title)
86 def __eq__(self, other):
87 return self.id.int == other.id.int
89 def __ne__(self, other):
90 return self.id.int != other.id.int
92 class WorkflowFactory():
93 #def __init__(self, *args, **kwargs):
95 Booking_Resource_Select,
107 SWConf_Resource_Select,
117 def conjure(self, workflow_type=None, repo=None):
125 steps = self.make_steps(workflow_types[workflow_type], repository=repo)
126 meta_steps = self.metaize(steps=steps, wf_type=workflow_type)
127 return steps, meta_steps
129 def make_steps(self, step_types, repository):
130 repository.el['steps'] += len(step_types)
132 for step_type in step_types:
133 steps.append(self.make_step(step_type, repository))
137 def make_step(self, step_type, repository):
138 iden = step_type.description + step_type.title + step_type.template
139 return step_type(iden, repository)
141 def metaize(self, steps, wf_type):
144 meta_step = MetaStep()
145 meta_step.short_title = step.short_title
146 meta_dict.append(meta_step)
147 step.metastep = meta_step