Java Solution Framework (SDK)
Introduction
The Solution Framework provides numerous components for the implementation of a Low-Code Project based on the project's design model. That means, whatever you modelled in the design phase will be reflected by pre-generated code.
SDK consists of some main packages under src/main/generated source folder:
api: which holds all API namespace's schema models, controllers and delegate classes
domain: which holds classes for all Entities, Services, Commands, Events and Agents that have been modeled in Domain Namespaces
integration: which contains classes and providers that allows for easy integration with dependent API(s) that have been added in Integration Namespaces
Solution engineers can use these generated classes to implement logic and interact with different modeled components.
Below are the main SDK components that can be used by solution engineers to help implementing project stubs logic.
Entity Builder
Groups all Entity Builders by Domain Namespace prefix.
Create Entities
Entity builders can be used to create an entity (Root Entity/Entity).
// Declare Entity Builder
@Autowired
EntityBuilder entityBuilder;
// Create a customer entity that exists in a domain namespace prefixed by cc.
Customer customer = entityBuilder.cc.customer()
.setCustomerId("Customer Id")
.setCustomerName("Joh Doe")
.setAmixCard(new AmixCard("some id", CardType.debit))
.build();
Create Events
Event builder can also be used to create an Event.
// Declare Event Builder
@Autowired
EventBuilder eventBuilder;
// Create a SuccessEvent that exists in a domain namespace prefixed by cc.
SuccessEvent event = eventBuilder.cc.successEvent().setPayload(payloadEntity).build();
Repository
Groups all Root Entity repositories by Domain Namespace prefix.
Repository can be used to do database CRUD operations for a Root Entity.
// Declare Repository
@Autowired
Repository repo;
// Build a credit card root entity that exists in a domain namespace prefixed by cc.
CreditCard creditCard = entityBuilder.cc.creditCard()
.setBankName("MyBank")
.setCardType(CardType.debit)
.setCustomer(customer)
.setIssueDate(OffsetDateTime.now())
.build();
// Save a credit card root entity.
creditCard = repo.cc.creditCard.save(creditCard);
// Retrieve all credit card root entities
List<CreditCard> cards = repo.cc.creditCard.findAll();
// Update credit card root entity
creditCard.setCardType(CardType.credit);
repo.cc.creditCard.save(creditCard);
// Delete credit card root entity
repo.cc.creditCard.delete(creditCard);
//Count all credit card root entities
long count = repo.cc.creditCard.count();
SimpleMongoRepository
, so it supports all database operations provided by SimpleMongoRepository. The repository is also accessible in project stub classes (Services, Commands, Agents) derived from their base classes.Command
Groups all Root Entity commands by Domain Namespace prefix.
Each root entity with commands will get a service class that will be implemented by solution engineers to provide commands logic.
// Declare Command
@Autowired
Command commands;
// Execute root entity credit card activateCard command logic.
commands.cc.creditCard.activateCard(creditCardInstrance);
Domain Service
Groups all Domain Services by Domain Namespace prefix.
Each service will get a service class that will be implemented by solution engineers to provide service logic.
// Declare Domain Service
@Autowired
DomainService services;
// Execute getCustomer service logic.
Customer customer = services.cc.getCustomer(serviceInputEntity);
Integration Service
Groups all Integration Services by Integration Namespace prefix.
Each service will get a service class that will be implemented by solution engineers to provide service logic.
// Declare Integration Service
@Autowired
IntegrationService services;
// Execute getIscore service logic.
Iscore iscoreInfo = services.credit.getIscore(customer);
API Dependency Provider
For each API Dependency added in Integration Namespaces, there will be a provider that allows for making REST calls to that dependent API endpoints.
// Declare Provider for an API Dependency called CNR
@Autowired
CNRApiProvider cnr;
// retrieve an offer from CNR API.
ResponseEntityl<Offer> offer = cnr.adjustOffer(customerNeedId,offerId);
Event Producer Service
Publish Domain Events to Kafka topics.
Each Domain Event is assigned to a Kafka topic and the event producer service can be used by solution engineers to publish events.
// Declare Event Prodcuer Service
@Autowired
EventProducerService eventProdcuer;
// Declare entity builder
@Autowired
EntityBuilder entityBuilder;
// Create payload entity
SuccessEventPayload payloadEntity = entityBuilder.cc.successEventPayload().build();
// Create domain event
SuccessEvent event = eventBuilder.cc.successEvent().setPayload(payloadEntity).build();
// Publish a domain event.
eventProducer.publish(event);