customer.spp
customer/customer.spp
Download original file · Petstore source contents
1domain customer;23Entity Person {4business("Customer-domain subject registration number") String customerNumber;5String name;6String email;7String address;8}910Contract SubjectRegistrationAgreement {11Person subject;12}1314Contract SubjectProfileAgreement {15Person subject;16String name;17String email;18String address;19}2021Role RegisteredSubject {22}2324take Person as RegisteredSubject {25takeall;26}2728Scenario serial readRegisteredSubject(RegisteredSubject) {29findRegisteredSubject;30}3132atomic check checkSubjectFacts(Person) {33require(Person.name != null && Person.name != "", "SUBJECT_NAME_REQUIRED");34require(Person.email != null && Person.email != "", "SUBJECT_EMAIL_REQUIRED");35require(Person.address != null && Person.address != "", "SUBJECT_ADDRESS_REQUIRED");36}3738atomic check checkSubjectAbsent(Person) {39require(!Person, "SUBJECT_EXISTS");40}4142atomic calculate prepareSubjectRegistration(Person, SubjectRegistrationAgreement) {43SubjectRegistrationAgreement.subject = Person;44}4546atomic calculate applySubjectProfile(Person, SubjectProfileAgreement) {47Person.name = SubjectProfileAgreement.name;48Person.email = SubjectProfileAgreement.email;49Person.address = SubjectProfileAgreement.address;50SubjectProfileAgreement.subject = Person;51}5253Scenario serial registerSubject(Person, SubjectRegistrationAgreement) {54checkSubjectFacts;55prepareSubjectRegistration;56findPerson;57checkSubjectAbsent;58transaction {59insertPerson;60}61}6263Scenario serial updateSubjectProfile(Person, SubjectProfileAgreement) {64findPerson;65identify(Person);66applySubjectProfile;67checkSubjectFacts;68transaction {69updatePerson;70}71}7273atomic calculate configureMerchantSubject(Person) {74Person.customerNumber = "MERCHANT-001";75Person.name = "Pet shop merchant";76Person.email = "merchant@example.test";77Person.address = "Pet Lane shop, Demo City";78}7980Scenario serial initializeCustomerDomain(Person, SubjectRegistrationAgreement) {81configureMerchantSubject;82prepareSubjectRegistration;83findPerson;84if (!Person) {85checkSubjectFacts;86transaction {87insertPerson;88}89}90}