tla-sbuilder 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +328 -0
- data/VERSION +1 -0
- data/bin/sbuilder.rb +5 -0
- data/lib/cli/cli-customer.rb +420 -0
- data/lib/cli/cli-example.rb +92 -0
- data/lib/cli/cli-pet.rb +767 -0
- data/lib/cli/cli-text.rb +226 -0
- data/lib/cli/cli.rb +298 -0
- data/lib/sbuilder.rb +52 -0
- data/lib/sbuilder/constants.rb +72 -0
- data/lib/sbuilder/controller.rb +798 -0
- data/lib/sbuilder/default-sbuilder.yaml +372 -0
- data/lib/sbuilder/domain.rb +124 -0
- data/lib/sbuilder/domain_cardinality.rb +37 -0
- data/lib/sbuilder/domain_value.rb +81 -0
- data/lib/sbuilder/exception.rb +27 -0
- data/lib/sbuilder/extension_loader.rb +721 -0
- data/lib/sbuilder/factory.rb +234 -0
- data/lib/sbuilder/model.rb +356 -0
- data/lib/sbuilder/mustache/template.rb +125 -0
- data/lib/sbuilder/mustache/template_reader.rb +206 -0
- data/lib/sbuilder/mustache/template_reader_context.rb +371 -0
- data/lib/sbuilder/param_set.rb +132 -0
- data/lib/sbuilder/param_set_db.rb +20 -0
- data/lib/sbuilder/param_set_def.rb +57 -0
- data/lib/sbuilder/param_set_if.rb +68 -0
- data/lib/sbuilder/param_set_loader.rb +77 -0
- data/lib/sbuilder/param_set_loader_swagger.rb +424 -0
- data/lib/sbuilder/param_set_step.rb +62 -0
- data/lib/sbuilder/param_sets.rb +54 -0
- data/lib/sbuilder/parameter.rb +97 -0
- data/lib/sbuilder/parameter_container.rb +72 -0
- data/lib/sbuilder/parameter_dom.rb +70 -0
- data/lib/sbuilder/parameter_ref.rb +71 -0
- data/lib/sbuilder/resolver.rb +78 -0
- data/lib/sbuilder/resolver_loader.rb +79 -0
- data/lib/sbuilder/resolver_loader_yaml.rb +103 -0
- data/lib/sbuilder/resolver_rule.rb +36 -0
- data/lib/sbuilder/resolver_rule_match.rb +55 -0
- data/lib/sbuilder/resolver_rule_ref.rb +37 -0
- data/lib/utils/hash_inject.rb +12 -0
- data/lib/utils/logger.rb +80 -0
- data/lib/utils/netio.rb +58 -0
- data/lib/utils/string_inject.rb +10 -0
- data/lib/utils/version.rb +13 -0
- data/mustache/cfg/const_def.mustache +8 -0
- data/mustache/cfg/const_run.mustache +3 -0
- data/mustache/cfg/invariant-infrastructure-service.mustache +4 -0
- data/mustache/cfg/macro_run.mustache +6 -0
- data/mustache/cfg/module_footer.mustache +0 -0
- data/mustache/cfg/module_header.mustache +7 -0
- data/mustache/data-model-dump.mustache +19 -0
- data/mustache/data-model-footer.mustache +5 -0
- data/mustache/data-model-header.mustache +16 -0
- data/mustache/definition_types.mustache +40 -0
- data/mustache/domains.mustache +20 -0
- data/mustache/domains_assign.mustache +22 -0
- data/mustache/domains_run.mustache +21 -0
- data/mustache/extend/extend_assumptions.mustache +7 -0
- data/mustache/extend/extend_const.mustache +5 -0
- data/mustache/extend/extend_implementation.mustache +9 -0
- data/mustache/extend/extend_invariant.mustache +7 -0
- data/mustache/extend/extend_invariant_cfg.mustache +7 -0
- data/mustache/extend/extend_macros.mustache +19 -0
- data/mustache/extend/extend_operations.mustache +9 -0
- data/mustache/extend/extend_state.mustache +9 -0
- data/mustache/infrastructure-service-init.mustache +36 -0
- data/mustache/infrastructure-service-variables.mustache +10 -0
- data/mustache/interface_processes.mustache +38 -0
- data/mustache/interface_stubs_dummy.mustache +13 -0
- data/mustache/interface_types.mustache +52 -0
- data/mustache/markdown-header.mustache +24 -0
- data/mustache/markdown-toc.mustache +13 -0
- data/mustache/name_definition_type.mustache +5 -0
- data/mustache/name_domain.mustache +5 -0
- data/mustache/name_domain_value.mustache +5 -0
- data/mustache/name_domain_value_prefix.mustache +5 -0
- data/mustache/name_interface_response_type.mustache +6 -0
- data/mustache/name_interface_type.mustache +6 -0
- data/mustache/name_parameter_definition.mustache +5 -0
- data/mustache/name_parameter_type.mustache +6 -0
- data/mustache/name_process.mustache +6 -0
- data/mustache/name_type_invariant.mustache +5 -0
- data/mustache/name_variable.mustache +6 -0
- data/mustache/operator-infrastructure-service.mustache +13 -0
- data/mustache/possibility/module_extends.mustache +1 -0
- data/mustache/possibility/module_footer.mustache +1 -0
- data/mustache/possibility/module_header.mustache +8 -0
- data/mustache/possibility/possibility_definition.mustache +12 -0
- data/mustache/possibility/possibility_directive.mustache +1 -0
- data/mustache/possibility/possility_setup.mustache +28 -0
- data/mustache/setup/module_footer.mustache +1 -0
- data/mustache/setup/module_header.mustache +9 -0
- data/mustache/setup/operator_run.mustache +7 -0
- data/mustache/setup/operator_tick.mustache +2 -0
- data/mustache/setup/steps_run.mustache +22 -0
- data/mustache/setup/steps_run_bind_rule.mustache +51 -0
- data/mustache/setup/steps_run_bind_set.mustache +37 -0
- data/mustache/setup/steps_run_parameterBind.mustache +80 -0
- data/mustache/setup/steps_run_parameterExact.mustache +79 -0
- data/mustache/state_type_invariant-infrastructure-service.mustache +49 -0
- data/mustache/state_type_invariant.mustache +17 -0
- data/mustache/state_type_invariant_cfg.mustache +18 -0
- data/mustache/state_variables.mustache +20 -0
- data/mustache/tla/const_def.mustache +5 -0
- data/mustache/tla/const_run.mustache +3 -0
- data/mustache/tla/macro-infrastructure-service.mustache +14 -0
- data/mustache/tla/macro_run.mustache +40 -0
- data/mustache/tla/module_footer.mustache +2 -0
- data/mustache/tla/module_header.mustache +9 -0
- data/mustache/tla/operator_run.mustache +8 -0
- data/mustache/tla/operators-infrastructure-service.mustache +12 -0
- data/mustache/tla/plc_define_footer.mustache +1 -0
- data/mustache/tla/plc_define_header.mustache +1 -0
- data/mustache/tla/plc_define_run.mustache +59 -0
- data/mustache/tla/plc_footer.mustache +2 -0
- data/mustache/tla/plc_header.mustache +2 -0
- data/mustache/tla/plc_run_state.mustache +12 -0
- data/mustache/tla/plc_tail.mustache +8 -0
- data/mustache/tla/plc_translation.mustache +2 -0
- data/resources/schema/json_schema/draft-04.json +150 -0
- data/resources/schema/swagger/2.0/schema.json +1591 -0
- data/src-extend/README +2 -0
- data/src-extend/extend/extend_assumptions.mustache +7 -0
- data/src-extend/extend/extend_const.mustache +5 -0
- data/src-extend/extend/extend_implementation.mustache +9 -0
- data/src-extend/extend/extend_invariant.mustache +11 -0
- data/src-extend/extend/extend_invariant_cfg.mustache +7 -0
- data/src-extend/extend/extend_macros.mustache +19 -0
- data/src-extend/extend/extend_operations.mustache +9 -0
- data/src-extend/extend/extend_state.mustache +9 -0
- data/src-extend/extend_app/assumption +20 -0
- data/src-extend/extend_app/correctness +19 -0
- data/src-extend/extend_app/correctness.cfg +9 -0
- data/src-extend/extend_app/infrastructure +25 -0
- data/src-extend/extend_app/interface +11 -0
- data/src-extend/extend_app/operator +18 -0
- data/src-extend/extend_app/possibility +16 -0
- data/src-extend/extend_app/service +33 -0
- data/src-extend/extend_app/state +16 -0
- data/src-extend/extend_app/transaction +22 -0
- data/src/pet/assumption +29 -0
- data/src/pet/assumption_address_domains.tla +12 -0
- data/src/pet/assumption_domains.tla +16 -0
- data/src/pet/assumption_generic.tla +8 -0
- data/src/pet/assumption_id_domains.tla +2 -0
- data/src/pet/assumption_owner_domains.tla +14 -0
- data/src/pet/assumption_pet_domains.tla +16 -0
- data/src/pet/assumption_tag_domains.tla +13 -0
- data/src/pet/correctness +24 -0
- data/src/pet/correctness.cfg +9 -0
- data/src/pet/correctness_coherent_owner_address.tla +6 -0
- data/src/pet/correctness_pet_name.tla +4 -0
- data/src/pet/correctness_ref_tag.tla +13 -0
- data/src/pet/correctness_type_invariants.tla +12 -0
- data/src/pet/correctness_unique_pet.tla +3 -0
- data/src/pet/correctness_unique_tag.tla +3 -0
- data/src/pet/docs/Petstore.md +117 -0
- data/src/pet/extend/extend_assumptions.mustache +7 -0
- data/src/pet/extend/extend_implementation.mustache +9 -0
- data/src/pet/extend/extend_invariant.mustache +11 -0
- data/src/pet/extend/extend_invariant_cfg.mustache +7 -0
- data/src/pet/extend/extend_macros.mustache +19 -0
- data/src/pet/extend/extend_operations.mustache +9 -0
- data/src/pet/extend/extend_state.mustache +9 -0
- data/src/pet/infrastructure +25 -0
- data/src/pet/infrastructure_id_get.tla +24 -0
- data/src/pet/interface +12 -0
- data/src/pet/interface_delete_pet.tla +5 -0
- data/src/pet/interface_get_pet.tla +4 -0
- data/src/pet/interface_post_pet.tla +5 -0
- data/src/pet/interface_post_tag.tla +5 -0
- data/src/pet/interface_put_tag.tla +3 -0
- data/src/pet/operator +30 -0
- data/src/pet/operator_find_tag_by_owner_name.tla +1 -0
- data/src/pet/operator_get_pet.tla +4 -0
- data/src/pet/operator_get_pet_by_tag.tla +4 -0
- data/src/pet/operator_get_tag.tla +10 -0
- data/src/pet/operator_new_owner.tla +3 -0
- data/src/pet/operator_new_pet.tla +13 -0
- data/src/pet/operator_new_tag.tla +3 -0
- data/src/pet/operator_next_pet_id.tla +3 -0
- data/src/pet/operator_responses.tla +8 -0
- data/src/pet/operator_tag_exists.tla +2 -0
- data/src/pet/operator_tag_owner_validated.tla +2 -0
- data/src/pet/operator_tag_referenced.tla +4 -0
- data/src/pet/operator_valid_owner.tla +17 -0
- data/src/pet/operator_valid_pet.tla +6 -0
- data/src/pet/operator_valid_tag.tla +5 -0
- data/src/pet/possibility +18 -0
- data/src/pet/possibility_at_least_two_tags.tla +12 -0
- data/src/pet/possibility_invalid_tag_address.tla +8 -0
- data/src/pet/service +35 -0
- data/src/pet/service_pet_delete.tla +11 -0
- data/src/pet/service_pet_get.tla +27 -0
- data/src/pet/service_pet_post.tla +78 -0
- data/src/pet/service_tag_post.tla +53 -0
- data/src/pet/service_tag_put.tla +82 -0
- data/src/pet/state +16 -0
- data/src/pet/state_infra.tla +6 -0
- data/src/pet/state_pet.tla +5 -0
- data/src/pet/state_tag_id.tla +2 -0
- data/src/pet/transaction +23 -0
- data/src/pet/transaction_delete_pet.tla +13 -0
- data/src/pet/transaction_enter_pet.tla +13 -0
- data/src/pet/transaction_enter_tag.tla +56 -0
- data/src/pet/transaction_error.tla +23 -0
- data/tla-sbuilder.gemspec +43 -0
- metadata +353 -0
@@ -0,0 +1,8 @@
|
|
1
|
+
(* ******************************************************************
|
2
|
+
|
3
|
+
Status messages
|
4
|
+
|
5
|
+
******************************************************************)
|
6
|
+
|
7
|
+
\* Error response object created (message left unused)
|
8
|
+
ResponseError( code, message ) == [ code |-> code, message |-> Nil ]
|
@@ -0,0 +1,17 @@
|
|
1
|
+
(*
|
2
|
+
* Valid address defines all fields
|
3
|
+
*)
|
4
|
+
|
5
|
+
ValidAddress( address ) == address.street # Nil
|
6
|
+
/\ address.city # Nil
|
7
|
+
|
8
|
+
|
9
|
+
(*
|
10
|
+
* Valid owner defines 'name' and has 'ValidAddress'
|
11
|
+
*)
|
12
|
+
ValidOwner( owner ) == owner.name # Nil /\ ValidAddress( owner.address )
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
data/src/pet/possibility
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
{{!
|
2
|
+
|
3
|
+
Define operator possibilities.
|
4
|
+
|
5
|
+
To activate the operators add per setup add name of the operator
|
6
|
+
to 'possibilities' arrays
|
7
|
+
|
8
|
+
setups:
|
9
|
+
- setupDirectory: setup1
|
10
|
+
possibilities:
|
11
|
+
- poss1
|
12
|
+
- poss2
|
13
|
+
|
14
|
+
|
15
|
+
}}
|
16
|
+
|
17
|
+
{{>possibility_at_least_two_tags.tla}}
|
18
|
+
{{>possibility_invalid_tag_address.tla}}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
(*
|
2
|
+
|
3
|
+
Define an operator 'at_least_two_tags' to check that
|
4
|
+
at least two entries are found in state variable 'v_tags'.
|
5
|
+
|
6
|
+
Having more than just one tag makes checking owner address coherence
|
7
|
+
more intersting.
|
8
|
+
|
9
|
+
*)
|
10
|
+
|
11
|
+
|
12
|
+
at_least_two_tags == Cardinality( v_tags ) > 1
|
data/src/pet/service
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
{{!
|
2
|
+
|
3
|
+
Procedures implmenting interface services.
|
4
|
+
|
5
|
+
Notice: Procedure is not necassarily needed if
|
6
|
+
service is fully implemented in interface entry-macro
|
7
|
+
(see interfaces_entry)
|
8
|
+
|
9
|
+
|
10
|
+
For example:
|
11
|
+
|
12
|
+
procedure delete_pet( delete_pet_input ) {
|
13
|
+
|
14
|
+
delete_pet_start:
|
15
|
+
|
16
|
+
\* transaction
|
17
|
+
delete_pet_trans( delete_pet_input );
|
18
|
+
|
19
|
+
return;
|
20
|
+
}
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
}}
|
25
|
+
|
26
|
+
{{>service_pet_post.tla}}
|
27
|
+
{{>service_pet_get.tla}}
|
28
|
+
{{>service_pet_delete.tla}}
|
29
|
+
{{>service_tag_post.tla}}
|
30
|
+
{{>service_tag_put.tla}}
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
procedure s_delete_pet( delete_pet_input ) {
|
2
|
+
|
3
|
+
delete_pet_start:
|
4
|
+
|
5
|
+
{{^PREFERENCES.debug-output}}\* {{/PREFERENCES.debug-output}}print <<"Pet delete", delete_pet_input, v_pets >>;
|
6
|
+
|
7
|
+
\* transaction
|
8
|
+
delete_pet_trans( delete_pet_input );
|
9
|
+
|
10
|
+
return;
|
11
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
(******************************************************************
|
2
|
+
Read pet by id
|
3
|
+
|
4
|
+
Data returned is validate. A system error is raised if validation
|
5
|
+
not successfull.
|
6
|
+
|
7
|
+
******************************************************************)
|
8
|
+
|
9
|
+
|
10
|
+
procedure s_get_pet( get_pet_input ) {
|
11
|
+
|
12
|
+
get_pet_start:
|
13
|
+
|
14
|
+
{{^PREFERENCES.debug-output}}\* {{/PREFERENCES.debug-output}}print <<"Pet get", get_pet_input >>;
|
15
|
+
|
16
|
+
if ( \A pet \in PetStore_GetPetById( get_pet_input.id ): ValidatePet( pet ) ) {
|
17
|
+
{{^PREFERENCES.debug-output}}\* {{/PREFERENCES.debug-output}}print <<"--> get ok", PetStore_GetPetById( get_pet_input.id )>>;
|
18
|
+
skip;
|
19
|
+
}
|
20
|
+
else {
|
21
|
+
pet_system_error( "Data integrity violated" );
|
22
|
+
};
|
23
|
+
|
24
|
+
get_pet_ret:
|
25
|
+
|
26
|
+
return;
|
27
|
+
}
|
@@ -0,0 +1,78 @@
|
|
1
|
+
(* ******************************************************************
|
2
|
+
Petstore post_pet: creates a new pet entry
|
3
|
+
|
4
|
+
- validate input
|
5
|
+
- validation ok --> enter_pet to database
|
6
|
+
- validation error --> raise an application error "pet input not valid"
|
7
|
+
|
8
|
+
* ******************************************************************)
|
9
|
+
procedure s_post_pet( input ) {
|
10
|
+
|
11
|
+
pet_post_start:
|
12
|
+
|
13
|
+
{{^PREFERENCES.debug-output}}\* {{/PREFERENCES.debug-output}} print <<"Pet post, input=", input >>;
|
14
|
+
|
15
|
+
(* Valid input received *)
|
16
|
+
if ( ~ValidatePetData( input.pet ) ) {
|
17
|
+
pet_application_error( "Invalid input" );
|
18
|
+
return;
|
19
|
+
};
|
20
|
+
|
21
|
+
pet_post_data_valid:
|
22
|
+
|
23
|
+
(* Referential integrity pet.tag --> tag.tag *)
|
24
|
+
if ( ~ValidTagExists( input.pet.tag ) ) {
|
25
|
+
{{^PREFERENCES.debug-output}}\* {{/PREFERENCES.debug-output}} print <<"Pet post, v_tags=", v_tags >>;
|
26
|
+
pet_application_error( "Tag not found" );
|
27
|
+
return;
|
28
|
+
};
|
29
|
+
|
30
|
+
|
31
|
+
pet_post_tag_exist:
|
32
|
+
|
33
|
+
if ( PetStore_GetPetByTag( input.pet.tag ) # {} ) {
|
34
|
+
|
35
|
+
{{^PREFERENCES.debug-output}}\* {{/PREFERENCES.debug-output}} print <<"Pet post, tag-not free, v_pets=", v_pets >>;
|
36
|
+
pet_application_error( "Tag not free" );
|
37
|
+
return;
|
38
|
+
};
|
39
|
+
|
40
|
+
|
41
|
+
pet_post_tag_valid_and_used:
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
(* Generate id using infrastructure service /id/{type}(get) *)
|
47
|
+
call infrastructure_id_get( "pet" );
|
48
|
+
|
49
|
+
post_pet_id_generated:
|
50
|
+
|
51
|
+
(* Id generation failure? *)
|
52
|
+
if ( InfrastructureServiceGetStatus( "/id/{type}(get)" ) # "status_200" ) {
|
53
|
+
|
54
|
+
{{^PREFERENCES.debug-output}}\* {{/PREFERENCES.debug-output}} print <<"Pet post, v_ids=", v_ids >>;
|
55
|
+
|
56
|
+
pet_application_error( "no id " );
|
57
|
+
return;
|
58
|
+
|
59
|
+
};
|
60
|
+
|
61
|
+
post_pet_ok:
|
62
|
+
|
63
|
+
assert( InfrastructureServiceGetStatus( "/id/{type}(get)" ) = "status_200"
|
64
|
+
/\ ValidatePet( New_Pet( input.pet, InfrastructureServiceGetResponse( "/id/{type}(get)" ).id ) )
|
65
|
+
);
|
66
|
+
|
67
|
+
|
68
|
+
(* Database transaction: create pet *)
|
69
|
+
enter_pet( New_Pet( input.pet, InfrastructureServiceGetResponse( "/id/{type}(get)" ).id ));
|
70
|
+
|
71
|
+
{{^PREFERENCES.debug-output}}\* {{/PREFERENCES.debug-output}} print <<"Pet post, SUCCESS!!, v_pets=", v_pets >>;
|
72
|
+
|
73
|
+
pet_post_done:
|
74
|
+
|
75
|
+
return;
|
76
|
+
|
77
|
+
}; \* post_pet
|
78
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
(*
|
2
|
+
* @param input.tag: t_Owner: of the new tag.
|
3
|
+
*
|
4
|
+
* Notice: owner name invalid if 'Nil'
|
5
|
+
* owner address invalid if any fields 'Nil'
|
6
|
+
*)
|
7
|
+
procedure s_post_tag( input ) {
|
8
|
+
|
9
|
+
post_tag_start:
|
10
|
+
|
11
|
+
{{^PREFERENCES.debug-output}}\* {{/PREFERENCES.debug-output}} print <<"Tag post, input=", input >>;
|
12
|
+
|
13
|
+
(* Validata input *)
|
14
|
+
if ( ~ValidateTagData( input.tag ) ) {
|
15
|
+
pet_application_error( "tag data not valid" );
|
16
|
+
return;
|
17
|
+
};
|
18
|
+
|
19
|
+
post_tag_validated_input:
|
20
|
+
|
21
|
+
(* Owner invalidation now allowed if Owner has already been validated *)
|
22
|
+
if ( TagOwnerValidated( input.tag ) /\ ~ValidOwner( input.tag ) ) {
|
23
|
+
|
24
|
+
{{^PREFERENCES.debug-output}}\* {{/PREFERENCES.debug-output}} print <<"Tag post, existing owners=", FindTagsByOwnerName( input.tag ) >>;
|
25
|
+
pet_application_error( "Owner invalidation not allowed" );
|
26
|
+
return;
|
27
|
+
};
|
28
|
+
|
29
|
+
post_tag_data_validated:
|
30
|
+
|
31
|
+
(* Generate id using infrastructure service /id/{type}(get) *)
|
32
|
+
call infrastructure_id_get( "tag" );
|
33
|
+
|
34
|
+
post_tag_id_generated:
|
35
|
+
|
36
|
+
(* Id generation failure? *)
|
37
|
+
if ( InfrastructureServiceGetStatus( "/id/{type}(get)" ) # "status_200" ) {
|
38
|
+
|
39
|
+
{{^PREFERENCES.debug-output}}\* {{/PREFERENCES.debug-output}} print <<"Tag post, v_ids=", v_ids >>;
|
40
|
+
pet_application_error( "no id " );
|
41
|
+
return;
|
42
|
+
};
|
43
|
+
|
44
|
+
|
45
|
+
post_tag_ok:
|
46
|
+
|
47
|
+
(* All checks passed: enter into database *)
|
48
|
+
enter_tag( New_Tag( input.tag, InfrastructureServiceGetResponse( "/id/{type}(get)" ).id ) );
|
49
|
+
|
50
|
+
post_tag_done:
|
51
|
+
|
52
|
+
return;
|
53
|
+
}
|
@@ -0,0 +1,82 @@
|
|
1
|
+
(*
|
2
|
+
* @param input.tag: t_Owner: of the tag
|
3
|
+
*)
|
4
|
+
procedure s_put_tag( input ) {
|
5
|
+
|
6
|
+
put_tag_start:
|
7
|
+
|
8
|
+
{{^PREFERENCES.debug-output}}\* {{/PREFERENCES.debug-output}} print <<"Tag put, input=", input >>;
|
9
|
+
|
10
|
+
(* Ensure that tag exists in the database *)
|
11
|
+
if ( Cardinality( GetTagtByIdentity( input.tag.tag ) ) # 1 ) {
|
12
|
+
|
13
|
+
pet_application_error( "unkown tag updated" );
|
14
|
+
return;
|
15
|
+
|
16
|
+
};
|
17
|
+
|
18
|
+
put_tag_exists:
|
19
|
+
|
20
|
+
(* Validate input *)
|
21
|
+
if ( ~ValidateTagData( input.tag ) ) {
|
22
|
+
pet_application_error( "tag data not valid" );
|
23
|
+
return;
|
24
|
+
};
|
25
|
+
|
26
|
+
|
27
|
+
put_tag_validated_input:
|
28
|
+
|
29
|
+
(* Tag is referenced in pets --> not allowed to invalidate (set to Nil) name *)
|
30
|
+
|
31
|
+
{{#PREFERENCES.error-invalidate-name}}
|
32
|
+
|
33
|
+
\* replace correct code will null operation
|
34
|
+
skip;
|
35
|
+
|
36
|
+
|
37
|
+
(* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
38
|
+
ERRROR
|
39
|
+
|
40
|
+
Invariant ValidReferecendTag is violated because we do not check
|
41
|
+
whether tag is referenced by some pet, when we are invalidating
|
42
|
+
owner name i.e. setting it to nil
|
43
|
+
pet to Nil
|
44
|
+
|
45
|
+
{{/PREFERENCES.error-invalidate-name}}
|
46
|
+
|
47
|
+
if ( input.tag.owner.name = Nil /\ TagReferenced( input.tag.tag ) ) {
|
48
|
+
|
49
|
+
pet_application_error( "Name invalidation not allowed" );
|
50
|
+
return;
|
51
|
+
};
|
52
|
+
|
53
|
+
{{#PREFERENCES.error-invalidate-name}}
|
54
|
+
|
55
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! *)
|
56
|
+
|
57
|
+
{{/PREFERENCES.error-invalidate-name}}
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
put_tag_not_invalidating_name:
|
62
|
+
|
63
|
+
if ( TagOwnerValidated( input.tag.owner ) /\ ~ValidOwner( input.tag.owner ) ) {
|
64
|
+
|
65
|
+
(* Tag owner is referenced in some tag --> address invalidation not allowed *)
|
66
|
+
|
67
|
+
{{^PREFERENCES.debug-output}}\* {{/PREFERENCES.debug-output}} print <<"Tag put, existing owners=", FindTagsByOwnerName( input.tag.owner ) >>;
|
68
|
+
pet_application_error( "Owner invalidation not allowed" );
|
69
|
+
return;
|
70
|
+
};
|
71
|
+
|
72
|
+
put_tag_ok:
|
73
|
+
|
74
|
+
(* Database transaction: update addresses & update existing tag *)
|
75
|
+
enter_tag( input.tag );
|
76
|
+
|
77
|
+
put_tag_done:
|
78
|
+
|
79
|
+
(* Assert that tag was changed *)
|
80
|
+
assert( { tag \in v_tags: tag.tag = input.tag.tag } = { input.tag } );
|
81
|
+
return;
|
82
|
+
}
|
data/src/pet/state
ADDED
data/src/pet/transaction
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
{{!
|
2
|
+
|
3
|
+
Place to define macros modifying application state.
|
4
|
+
|
5
|
+
For example:
|
6
|
+
|
7
|
+
macro enter_pet( new_pet ) {
|
8
|
+
|
9
|
+
v_pets := v_pets \union { new_pet };
|
10
|
+
|
11
|
+
}
|
12
|
+
|
13
|
+
}}
|
14
|
+
|
15
|
+
|
16
|
+
{{>transaction_error.tla}}
|
17
|
+
{{>transaction_enter_pet.tla}}
|
18
|
+
{{>transaction_delete_pet.tla}}
|
19
|
+
{{>transaction_enter_tag.tla}}
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|