tricc-oo 1.4.18__tar.gz → 1.4.20__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/PKG-INFO +1 -1
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/pyproject.toml +1 -1
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/converters/cql_to_operation.py +17 -4
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/converters/drawio_type_map.py +2 -2
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/models/base.py +14 -7
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/serializers/xls_form.py +2 -3
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/strategies/output/xlsform_cht.py +1 -1
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/visitors/tricc.py +110 -81
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo.egg-info/PKG-INFO +1 -1
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/README.md +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/setup.cfg +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tests/build.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tests/test_cql.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tests/to_ocl.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/__init__.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/converters/__init__.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/converters/codesystem_to_ocl.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/converters/cql/cqlLexer.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/converters/cql/cqlListener.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/converters/cql/cqlParser.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/converters/cql/cqlVisitor.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/converters/datadictionnary.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/converters/tricc_to_xls_form.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/converters/utils.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/converters/xml_to_tricc.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/models/__init__.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/models/calculate.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/models/lang.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/models/ocl.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/models/ordered_set.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/models/tricc.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/parsers/__init__.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/parsers/xml.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/serializers/__init__.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/serializers/planuml.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/strategies/__init__.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/strategies/input/__init__.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/strategies/input/base_input_strategy.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/strategies/input/drawio.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/strategies/output/base_output_strategy.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/strategies/output/spice.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/strategies/output/xls_form.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/strategies/output/xlsform_cdss.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/strategies/output/xlsform_cht_hf.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/visitors/__init__.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/visitors/utils.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo/visitors/xform_pd.py +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo.egg-info/SOURCES.txt +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo.egg-info/dependency_links.txt +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo.egg-info/requires.txt +0 -0
- {tricc_oo-1.4.18 → tricc_oo-1.4.20}/tricc_oo.egg-info/top_level.txt +0 -0
|
@@ -33,6 +33,7 @@ FUNCTION_MAP = {
|
|
|
33
33
|
class cqlToXlsFormVisitor(cqlVisitor):
|
|
34
34
|
def __init__(self):
|
|
35
35
|
self.xlsform_rows = []
|
|
36
|
+
self.errors= []
|
|
36
37
|
|
|
37
38
|
def resolve_scv(self, arg):
|
|
38
39
|
|
|
@@ -42,9 +43,15 @@ class cqlToXlsFormVisitor(cqlVisitor):
|
|
|
42
43
|
# if no code or not found return None
|
|
43
44
|
if arg.startswith('"') and arg.endswith('"'):
|
|
44
45
|
return TriccReference(arg[1:-1])
|
|
45
|
-
|
|
46
|
+
elif arg.lower() in ['true', 'false']:
|
|
47
|
+
return TriccStatic(arg.lower() == 'true')
|
|
48
|
+
elif arg != 'runner':
|
|
49
|
+
self.errors.append(f"'{arg}' will be poccessed as reference ")
|
|
46
50
|
return TriccReference(arg)
|
|
47
51
|
|
|
52
|
+
else:
|
|
53
|
+
return 'runner'
|
|
54
|
+
|
|
48
55
|
def translate(self, arg, type=ANY):
|
|
49
56
|
return self.resolve_scv(arg) or str(arg)
|
|
50
57
|
|
|
@@ -368,13 +375,13 @@ class CQLErrorListener(ErrorListener):
|
|
|
368
375
|
self.errors.append(error)
|
|
369
376
|
|
|
370
377
|
def transform_cql_to_operation(cql_input, context=None):
|
|
371
|
-
|
|
378
|
+
lib_input = f"""
|
|
372
379
|
library runner
|
|
373
380
|
|
|
374
381
|
define "calc":
|
|
375
382
|
{cql_input.replace('−', '-')}
|
|
376
383
|
"""
|
|
377
|
-
input_stream = InputStream(chr(10).join(
|
|
384
|
+
input_stream = InputStream(chr(10).join(lib_input.split('\n')))
|
|
378
385
|
lexer = cqlLexer(input_stream)
|
|
379
386
|
stream = CommonTokenStream(lexer)
|
|
380
387
|
parser = cqlParser(stream)
|
|
@@ -390,12 +397,18 @@ def transform_cql_to_operation(cql_input, context=None):
|
|
|
390
397
|
# Check for errors
|
|
391
398
|
if error_listener.errors:
|
|
392
399
|
for error in error_listener.errors:
|
|
393
|
-
print(f"CQL Grammar Error: {error}")
|
|
400
|
+
print(f"CQL Grammar Error: {error} \n in:\n {cql_input}")
|
|
394
401
|
return None # Or handle errors as appropriate for your use case
|
|
395
402
|
|
|
396
403
|
# If no errors, proceed with visitor
|
|
397
404
|
visitor = cqlToXlsFormVisitor()
|
|
405
|
+
|
|
398
406
|
visitor.visit(tree)
|
|
407
|
+
if visitor.errors:
|
|
408
|
+
logger.warning(f"while visiting cql: \n{cql_input}")
|
|
409
|
+
for e in visitor.errors:
|
|
410
|
+
logger.warning(e)
|
|
411
|
+
|
|
399
412
|
return visitor.xlsform_rows[0]['calculation']
|
|
400
413
|
|
|
401
414
|
def transform_cql_lib_to_operations(cql_input):
|
|
@@ -94,13 +94,13 @@ TYPE_MAP = {
|
|
|
94
94
|
|
|
95
95
|
TriccNodeType.text: {
|
|
96
96
|
"objects": ["UserObject", "object"],
|
|
97
|
-
"attributes": ["relevance"],
|
|
97
|
+
"attributes": ["save", "relevance"],
|
|
98
98
|
"mandatory_attributes": ["label", 'name'],
|
|
99
99
|
"model": TriccNodeText
|
|
100
100
|
},
|
|
101
101
|
TriccNodeType.date: {
|
|
102
102
|
"objects": ["UserObject", "object"],
|
|
103
|
-
"attributes": ["relevance"],
|
|
103
|
+
"attributes": ["save", "relevance"],
|
|
104
104
|
"mandatory_attributes": ["label", "name"],
|
|
105
105
|
"model": TriccNodeDate
|
|
106
106
|
},
|
|
@@ -112,7 +112,14 @@ class TriccBaseModel(BaseModel):
|
|
|
112
112
|
version: int = 1
|
|
113
113
|
def get_datatype(self):
|
|
114
114
|
return self.datatype or self.tricc_type
|
|
115
|
-
|
|
115
|
+
|
|
116
|
+
def get_next_instance(self):
|
|
117
|
+
if getattr(self, 'instances', None):
|
|
118
|
+
return max(100, *[n.instance for n in self.instances.values()]) + 1
|
|
119
|
+
if getattr(self, 'base_instance', None) and getattr(self.base_instance, 'instances', None):
|
|
120
|
+
return max(100, *[n.instance for n in self.base_instance.instances.values()]) + 1
|
|
121
|
+
return max(100,self.instance) + 1
|
|
122
|
+
|
|
116
123
|
def to_dict(self):
|
|
117
124
|
return {key: value for key, value in vars(self).items() if not key.startswith('_')}
|
|
118
125
|
|
|
@@ -233,20 +240,20 @@ class TriccNodeBaseModel(TriccBaseModel):
|
|
|
233
240
|
# to be updated while processing because final expression will be possible to build$
|
|
234
241
|
# #only the last time the script will go through the node (all prev node expression would be created
|
|
235
242
|
def get_name(self):
|
|
236
|
-
result = str(super().get_name())
|
|
243
|
+
result = self.__class__.__name__[9:]# str(super().get_name())
|
|
237
244
|
name = getattr(self, 'name', None)
|
|
238
245
|
label = getattr(self, 'label', None)
|
|
239
246
|
|
|
240
247
|
if name:
|
|
241
|
-
result
|
|
248
|
+
result += name
|
|
242
249
|
if label:
|
|
243
|
-
result
|
|
250
|
+
result += "::" + (
|
|
244
251
|
next(iter(self.label.values())) if isinstance(self.label, Dict) else self.label
|
|
245
252
|
)
|
|
246
|
-
if len(result) <
|
|
253
|
+
if len(result) < 80:
|
|
247
254
|
return result
|
|
248
255
|
else:
|
|
249
|
-
return result[:
|
|
256
|
+
return result[:80]
|
|
250
257
|
|
|
251
258
|
|
|
252
259
|
|
|
@@ -305,7 +312,7 @@ class TriccStatic(BaseModel):
|
|
|
305
312
|
return str(self.value)
|
|
306
313
|
|
|
307
314
|
def __repr__(self):
|
|
308
|
-
return "
|
|
315
|
+
return self.__class__.__name__+":"+str(type(self.value))+':' +str(self.value)
|
|
309
316
|
|
|
310
317
|
def get_references(self):
|
|
311
318
|
return OrderedSet()
|
|
@@ -62,12 +62,11 @@ def start_group(
|
|
|
62
62
|
|
|
63
63
|
if not relevance:
|
|
64
64
|
relevance_expression = ""
|
|
65
|
-
elif isinstance(relevance_expression, TriccOperation):
|
|
65
|
+
elif isinstance(relevance_expression, (TriccOperation, TriccStatic)):
|
|
66
66
|
relevance_expression = strategy.get_tricc_operation_expression(
|
|
67
67
|
relevance_expression
|
|
68
68
|
)
|
|
69
|
-
|
|
70
|
-
relevance_expression = str(relevance_expression.value)
|
|
69
|
+
|
|
71
70
|
|
|
72
71
|
# elif is_activity:
|
|
73
72
|
# relevance_expression = TRICC_CALC_EXPRESSION.format(get_export_name(cur_group.root))
|
|
@@ -117,7 +117,7 @@ class XLSFormCHTStrategy(XLSFormCDSSStrategy):
|
|
|
117
117
|
# pause
|
|
118
118
|
ends = []
|
|
119
119
|
for p in self.project.pages.values():
|
|
120
|
-
p_ends = list(filter(lambda x: issubclass(x.__class__, TriccNodeEnd) and getattr(x, '
|
|
120
|
+
p_ends = list(filter(lambda x: issubclass(x.__class__, TriccNodeEnd) and getattr(x, 'process', '') == 'pause', p.nodes.values() ))
|
|
121
121
|
if p_ends:
|
|
122
122
|
ends += p_ends
|
|
123
123
|
if ends:
|
|
@@ -93,6 +93,81 @@ def get_node_expressions(node, processed_nodes, process=None):
|
|
|
93
93
|
expression = TriccStatic(True)
|
|
94
94
|
return expression
|
|
95
95
|
|
|
96
|
+
def set_last_version_false(node, processed_nodes):
|
|
97
|
+
node_name = node.name if not isinstance(node, TriccNodeEnd) else node.get_reference()
|
|
98
|
+
last_version = get_last_version(node_name, processed_nodes) if issubclass(node.__class__, (TriccNodeDisplayModel, TriccNodeDisplayCalculateBase, TriccNodeEnd)) and not isinstance(node, TriccNodeSelectOption) else None
|
|
99
|
+
#last_version = processed_nodes.find_prev(node, lambda item: hasattr(item, 'name') and item.name == node.name)
|
|
100
|
+
if last_version and getattr(node, 'process', '') != 'pause':
|
|
101
|
+
# 0-100 for manually specified instance. 100-200 for auto instance
|
|
102
|
+
node.version = last_version.version + 1
|
|
103
|
+
last_version.last = False
|
|
104
|
+
node.path_len = max(node.path_len, last_version.path_len + 1)
|
|
105
|
+
return last_version
|
|
106
|
+
|
|
107
|
+
def get_version_inheritance(node, last_version, processed_nodes):
|
|
108
|
+
# FIXME this is for XLS form where only calculate are evaluated for a activity that is not triggered
|
|
109
|
+
if not issubclass(node.__class__, (TriccNodeInputModel)):
|
|
110
|
+
node.last = True
|
|
111
|
+
if (
|
|
112
|
+
issubclass(node.__class__, (TriccNodeDisplayCalculateBase, TriccNodeEnd)) and node.name is not None
|
|
113
|
+
):
|
|
114
|
+
#logger.debug("set last to false for node {} and add its link it to next one".format(last_used_calc.get_name()))
|
|
115
|
+
if node.prev_nodes:
|
|
116
|
+
set_prev_next_node(last_version, node)
|
|
117
|
+
else:
|
|
118
|
+
expression = node.expression or node.expression_reference or getattr(node, 'relevance', None)
|
|
119
|
+
datatype = expression.get_datatype()
|
|
120
|
+
if datatype == 'boolean':
|
|
121
|
+
expression_reference = TriccOperation(
|
|
122
|
+
TriccOperator.OR,
|
|
123
|
+
[TriccOperation(TriccOperator.ISTRUE, [last_version]), expression]
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
elif datatype == 'number':
|
|
127
|
+
expression = TriccOperation(
|
|
128
|
+
TriccOperator.PLUS,
|
|
129
|
+
[last_version, expression]
|
|
130
|
+
)
|
|
131
|
+
else:
|
|
132
|
+
expression = TriccOperation(
|
|
133
|
+
TriccOperator.COALESCE,
|
|
134
|
+
[last_version, expression]
|
|
135
|
+
)
|
|
136
|
+
if node.expression:
|
|
137
|
+
node.expression = expression
|
|
138
|
+
elif node.expression_reference:
|
|
139
|
+
node.expression_reference = expression
|
|
140
|
+
elif node.relevance:
|
|
141
|
+
node.relevance = expression
|
|
142
|
+
else:
|
|
143
|
+
node.last = False
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
calc = TriccNodeCalculate(
|
|
147
|
+
id=generate_id(f"save{node.id}"),
|
|
148
|
+
name=node.name,
|
|
149
|
+
path_len=node.path_len+1,
|
|
150
|
+
version=get_next_version(node.name, processed_nodes, node.version+2),
|
|
151
|
+
expression=TriccOperation(
|
|
152
|
+
TriccOperator.COALESCE,
|
|
153
|
+
[node, last_version, TriccStatic("''")]
|
|
154
|
+
),
|
|
155
|
+
last=True,
|
|
156
|
+
activity=node.activity,
|
|
157
|
+
group=node.group
|
|
158
|
+
)
|
|
159
|
+
node.activity.nodes[calc.id]=calc
|
|
160
|
+
node.activity.calculates.append(calc)
|
|
161
|
+
set_last_version_false(calc, processed_nodes)
|
|
162
|
+
processed_nodes.add(calc)
|
|
163
|
+
if issubclass(node.__class__, TriccNodeInputModel):
|
|
164
|
+
node.expression = TriccOperation(
|
|
165
|
+
TriccOperator.COALESCE,
|
|
166
|
+
[
|
|
167
|
+
'$this',
|
|
168
|
+
last_version
|
|
169
|
+
]
|
|
170
|
+
)
|
|
96
171
|
|
|
97
172
|
def process_calculate(node,processed_nodes, stashed_nodes, calculates, used_calculates,
|
|
98
173
|
warn = False, process=None, **kwargs ):
|
|
@@ -117,76 +192,11 @@ def process_calculate(node,processed_nodes, stashed_nodes, calculates, used_calc
|
|
|
117
192
|
):
|
|
118
193
|
if kwargs.get('warn', True):
|
|
119
194
|
logger.debug('Processing relevance for node {0}'.format(node.get_name()))
|
|
120
|
-
|
|
121
|
-
last_version = get_last_version(node_name, processed_nodes) if issubclass(node.__class__, (TriccNodeDisplayModel, TriccNodeDisplayCalculateBase, TriccNodeEnd)) and not isinstance(node, TriccNodeSelectOption) else None
|
|
122
|
-
#last_version = processed_nodes.find_prev(node, lambda item: hasattr(item, 'name') and item.name == node.name)
|
|
195
|
+
last_version = set_last_version_false(node, processed_nodes)
|
|
123
196
|
if last_version:
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
node.path_len = max(node.path_len, last_version.path_len + 1)
|
|
128
|
-
# FIXME this is for XLS form where only calculate are evaluated for a activity that is not triggered
|
|
129
|
-
if not issubclass(node.__class__, (TriccNodeInputModel)):
|
|
130
|
-
node.last = True
|
|
131
|
-
if (
|
|
132
|
-
issubclass(node.__class__, (TriccNodeDisplayCalculateBase, TriccNodeEnd)) and node.name is not None
|
|
133
|
-
):
|
|
134
|
-
#logger.debug("set last to false for node {} and add its link it to next one".format(last_used_calc.get_name()))
|
|
135
|
-
if node.prev_nodes:
|
|
136
|
-
set_prev_next_node(last_version, node)
|
|
137
|
-
else:
|
|
138
|
-
expression = node.expression or node.expression_reference or node.relevance
|
|
139
|
-
datatype = expression.get_datatype()
|
|
140
|
-
if datatype == 'boolean':
|
|
141
|
-
expression_reference = TriccOperation(
|
|
142
|
-
TriccOperator.OR,
|
|
143
|
-
[TriccOperation(TriccOperator.ISTRUE, [last_version]), expression]
|
|
144
|
-
)
|
|
145
|
-
|
|
146
|
-
elif datatype == 'number':
|
|
147
|
-
expression = TriccOperation(
|
|
148
|
-
TriccOperator.PLUS,
|
|
149
|
-
[last_version, expression]
|
|
150
|
-
)
|
|
151
|
-
else:
|
|
152
|
-
expression = TriccOperation(
|
|
153
|
-
TriccOperator.COALESCE,
|
|
154
|
-
[last_version, expression]
|
|
155
|
-
)
|
|
156
|
-
if node.expression:
|
|
157
|
-
node.expression = expression
|
|
158
|
-
elif node.expression_reference:
|
|
159
|
-
node.expression_reference = expression
|
|
160
|
-
elif node.relevance:
|
|
161
|
-
node.relevance = expression
|
|
162
|
-
else:
|
|
163
|
-
node.last = False
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
calc = TriccNodeCalculate(
|
|
167
|
-
id=generate_id(f"save{node.id}"),
|
|
168
|
-
name=node.name,
|
|
169
|
-
path_len=node.path_len+1,
|
|
170
|
-
version=last_version.version + 2,
|
|
171
|
-
expression=TriccOperation(
|
|
172
|
-
TriccOperator.COALESCE,
|
|
173
|
-
[node, last_version, TriccStatic("''")]
|
|
174
|
-
),
|
|
175
|
-
last=True,
|
|
176
|
-
activity=node.activity,
|
|
177
|
-
group=node.group
|
|
178
|
-
)
|
|
179
|
-
node.activity.nodes[calc.id]=calc
|
|
180
|
-
node.activity.calculates.append(calc)
|
|
181
|
-
if issubclass(node.__class__, TriccNodeInputModel):
|
|
182
|
-
node.expression = TriccOperation(
|
|
183
|
-
TriccOperator.COALESCE,
|
|
184
|
-
[
|
|
185
|
-
'$this',
|
|
186
|
-
last_version
|
|
187
|
-
]
|
|
188
|
-
)
|
|
189
|
-
|
|
197
|
+
last_version = get_version_inheritance(node, last_version, processed_nodes)
|
|
198
|
+
generate_calculates(node,calculates, used_calculates,processed_nodes=processed_nodes)
|
|
199
|
+
|
|
190
200
|
|
|
191
201
|
|
|
192
202
|
# if has prev, create condition
|
|
@@ -218,7 +228,6 @@ def process_calculate(node,processed_nodes, stashed_nodes, calculates, used_calc
|
|
|
218
228
|
if issubclass(r.__class__, (TriccNodeDisplayCalculateBase )):
|
|
219
229
|
add_used_calculate(node, r, calculates, used_calculates, processed_nodes)
|
|
220
230
|
|
|
221
|
-
generate_calculates(node,calculates, used_calculates,processed_nodes=processed_nodes)
|
|
222
231
|
if last_version and hasattr(node, 'relevance'):
|
|
223
232
|
if isinstance(node, TriccNodeInputModel):
|
|
224
233
|
version_relevance = TriccOperation(
|
|
@@ -468,16 +477,23 @@ def generate_calculates(node,calculates, used_calculates,processed_nodes):
|
|
|
468
477
|
calc_node.path_len += 1
|
|
469
478
|
calc_node.name=calculate_name
|
|
470
479
|
calc_node.label = "save select: " +node.get_name()
|
|
471
|
-
|
|
480
|
+
elif node.name != calculate_name:
|
|
472
481
|
calc_id = generate_id(f"autosave{node.id}")
|
|
482
|
+
|
|
473
483
|
calc_node = TriccNodeCalculate(
|
|
474
484
|
name=calculate_name,
|
|
475
485
|
id = calc_id,
|
|
476
486
|
group = node.group,
|
|
487
|
+
version=get_next_version(calculate_name, processed_nodes, node.version+2),
|
|
477
488
|
activity = node.activity,
|
|
478
489
|
label = "save: " +node.get_name(),
|
|
479
|
-
path_len=node.path_len+ 1
|
|
490
|
+
path_len=node.path_len+ 1,
|
|
491
|
+
last=True
|
|
480
492
|
)
|
|
493
|
+
node.activity.nodes[calc_node.id]=calc_node
|
|
494
|
+
node.activity.calculates.append(calc_node)
|
|
495
|
+
set_last_version_false(calc_node, processed_nodes)
|
|
496
|
+
processed_nodes.add(calc_node)
|
|
481
497
|
logger.debug("generate_save_calculate:{}:{} as {}".format(calc_node.tricc_type, node.name if hasattr(node,'name') else node.id, calculate_name))
|
|
482
498
|
if isinstance(node, TriccNodeSelectYesNo):
|
|
483
499
|
yesNode = node.options[0]
|
|
@@ -526,12 +542,15 @@ def process_reference(node, processed_nodes, calculates, used_calculates=None,
|
|
|
526
542
|
node.reference = list(modified_expression.get_references())
|
|
527
543
|
node.expression_reference = modified_expression
|
|
528
544
|
elif getattr(node, 'reference', None):
|
|
529
|
-
|
|
545
|
+
reference = node.reference
|
|
546
|
+
if isinstance(reference, list):
|
|
547
|
+
if isinstance(node, TriccNodeWait):
|
|
548
|
+
reference = [TriccOperation(TriccOperator.ISTRUE,[n]) for n in reference]
|
|
530
549
|
if len(node.reference) == 1 :
|
|
531
|
-
operation =
|
|
550
|
+
operation = reference[0]
|
|
532
551
|
else:
|
|
533
552
|
operation = and_join(
|
|
534
|
-
|
|
553
|
+
reference
|
|
535
554
|
)
|
|
536
555
|
modified_expression = process_operation_reference(
|
|
537
556
|
operation,
|
|
@@ -945,6 +964,9 @@ def walkthrough_tricc_option(node, callback, processed_nodes, stashed_nodes, pat
|
|
|
945
964
|
warn = warn,
|
|
946
965
|
node_path = node_path.copy(), **kwargs)
|
|
947
966
|
|
|
967
|
+
def get_next_version(name, processed_nodes, version=0,):
|
|
968
|
+
return max(version, 100,*[(getattr(n,'version',0) or getattr(n,'instance',0) or 0) for n in get_versions(name, processed_nodes)])
|
|
969
|
+
|
|
948
970
|
|
|
949
971
|
def get_data_for_log(node):
|
|
950
972
|
return "{}:{}|{} {}:{}".format(
|
|
@@ -1204,6 +1226,7 @@ def get_all_dependant(loop, stashed_nodes, processed_nodes, depth=0, waited=None
|
|
|
1204
1226
|
looped = {}
|
|
1205
1227
|
if waited is None:
|
|
1206
1228
|
waited = {}
|
|
1229
|
+
all_dependant = OrderedSet()
|
|
1207
1230
|
for n in loop:
|
|
1208
1231
|
cur_path = path.copy()
|
|
1209
1232
|
cur_path.append(n)
|
|
@@ -1219,7 +1242,7 @@ def get_all_dependant(loop, stashed_nodes, processed_nodes, depth=0, waited=None
|
|
|
1219
1242
|
pass
|
|
1220
1243
|
for d in dependant:
|
|
1221
1244
|
if d in path:
|
|
1222
|
-
logger.warning(f"loop {str(d)} already in path {'::'.join(map(
|
|
1245
|
+
logger.warning(f"loop {str(d)} already in path {'::'.join(map(str, path))} ")
|
|
1223
1246
|
if isinstance(d, TriccNodeSelectOption):
|
|
1224
1247
|
d = d.select
|
|
1225
1248
|
|
|
@@ -1235,9 +1258,10 @@ def get_all_dependant(loop, stashed_nodes, processed_nodes, depth=0, waited=None
|
|
|
1235
1258
|
looped = add_to_tree(looped, n, d)
|
|
1236
1259
|
else :
|
|
1237
1260
|
waited = add_to_tree(waited, n, d)
|
|
1261
|
+
all_dependant = all_dependant.union(dependant)
|
|
1238
1262
|
if depth < MAX_DRILL:
|
|
1239
|
-
|
|
1240
|
-
|
|
1263
|
+
waited, looped = get_all_dependant(all_dependant, stashed_nodes, processed_nodes, depth+1, waited , looped, path=cur_path)
|
|
1264
|
+
|
|
1241
1265
|
return waited, looped
|
|
1242
1266
|
|
|
1243
1267
|
|
|
@@ -1468,7 +1492,7 @@ def get_node_expression( in_node, processed_nodes, is_calculate=False, is_prev=F
|
|
|
1468
1492
|
expression = None
|
|
1469
1493
|
negate_expression = None
|
|
1470
1494
|
node = in_node
|
|
1471
|
-
if isinstance(node, (TriccNodeActivityStart,TriccNodeMainStart
|
|
1495
|
+
if isinstance(node, (TriccNodeActivityStart,TriccNodeMainStart)):
|
|
1472
1496
|
if is_prev and is_calculate:
|
|
1473
1497
|
expression = get_node_expression(
|
|
1474
1498
|
node.activity,
|
|
@@ -1478,7 +1502,9 @@ def get_node_expression( in_node, processed_nodes, is_calculate=False, is_prev=F
|
|
|
1478
1502
|
negate=negate,
|
|
1479
1503
|
process=process
|
|
1480
1504
|
)
|
|
1481
|
-
|
|
1505
|
+
if isinstance(node, TriccNodeMainStart):
|
|
1506
|
+
expression = get_applicability_expression(node.activity, processed_nodes, process, expression )
|
|
1507
|
+
elif isinstance(node, (TriccNodeActivityStart)):
|
|
1482
1508
|
return None
|
|
1483
1509
|
|
|
1484
1510
|
elif isinstance(node, TriccNodeWait):
|
|
@@ -1538,7 +1564,7 @@ def get_node_expression( in_node, processed_nodes, is_calculate=False, is_prev=F
|
|
|
1538
1564
|
# else:
|
|
1539
1565
|
expression = node.expression_reference
|
|
1540
1566
|
elif not is_prev and hasattr(node, 'relevance') and isinstance(node.relevance, TriccOperation):
|
|
1541
|
-
expression = node.relevance
|
|
1567
|
+
expression = node.relevance
|
|
1542
1568
|
elif is_prev and isinstance(node, TriccNodeSelectOption):
|
|
1543
1569
|
if negate:
|
|
1544
1570
|
negate_expression = get_selected_option_expression(node, negate)
|
|
@@ -1625,6 +1651,9 @@ def get_process_skip_expression(node, processed_nodes, process, expression=None)
|
|
|
1625
1651
|
f_end_expression = get_end_expression(processed_nodes)
|
|
1626
1652
|
if f_end_expression:
|
|
1627
1653
|
end_expressions.append(f_end_expression)
|
|
1654
|
+
b_end_expression = get_end_expression(processed_nodes, 'pause')
|
|
1655
|
+
if b_end_expression:
|
|
1656
|
+
end_expressions.append(b_end_expression)
|
|
1628
1657
|
if process[0] in PROCESSES:
|
|
1629
1658
|
for p in PROCESSES[PROCESSES.index(process[0])+1:]:
|
|
1630
1659
|
p_end_expression = get_end_expression(processed_nodes, p)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|