Java Low-Code Solution SDK Components
-
SDK consists of two main packages under src/main/generated source folder
- Api which holds all API layer schema models, controllers and delegate classes.
- Domain which holds classes for all Entities, services, commands, events and agents that is modeled in domain layer.
- Integration which conntains classes and providers that allows for easy integration with dependent API(s) that is added in integration layer.
-
Solution engineer can use these generated classes to implement logic and intreact with different modeled components.
-
Below are the main SDK components that can be used by solution engineer to help implementing solution stubs logic.
Entity Builder
Groups all Entity builders by domain namespace prefix.
Entity builder 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();
Event Builder
Groups all Event builders by domain namespace prefix.
Event builder can be used to create an Event.
// Declare Event Builder
@Autowired
EventBuilder eventBuilder;
// Create a SucessEvent that exists in a domain namespace prefixed by cc.
SucessEvent event = eventBuilder.cc.sucessEvent().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();
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 engineer 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 engineer 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 engineer 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 namespace, 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, event producer service can be used by solution engineer 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
SucessEvent event = eventBuilder.cc.sucessEvent().setPayload(payloadEntity).build();
// Publish a domain event.
eventProdcuer.publish(event);