Skip to content

Commit

Permalink
Merge pull request #2 from ContextMapper/feature/generate-comments-on…
Browse files Browse the repository at this point in the history
…-aggregates-and-entities

Generate comments on aggregates and entities
  • Loading branch information
stefan-ka authored Nov 2, 2019
2 parents dd4ca62 + d749d74 commit 27c1982
Show file tree
Hide file tree
Showing 12 changed files with 354 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Examples/LakesideMutual/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repositories {
}

dependencies {
implementation 'org.contextmapper:context-map-discovery:0.1.0'
implementation 'org.contextmapper:context-map-discovery:0.2.0-SNAPSHOT'

// lakeside mutual dependencies (local Maven repo)
implementation 'com.lakesidemutual:customer-core:0.0.1-SNAPSHOT'
Expand Down
234 changes: 234 additions & 0 deletions Examples/LakesideMutual/src-gen/lakesidemutual.cml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,251 @@ ContextMap {

BoundedContext PolicyManagement {
implementationTechnology "Spring Boot"
// This Aggregate has been created on the basis of the Spring REST controller com.lakesidemutual.policymanagement.interfaces.RiskComputationService.
Aggregate riskfactor
// This Aggregate has been created on the basis of the Spring REST controller com.lakesidemutual.policymanagement.interfaces.InsuranceQuoteRequestInformationHolder.
Aggregate PolicyManagement_insurance_quote_requests {
// This entity has been derived from the class com.lakesidemutual.policymanagement.interfaces.dtos.insurancequoterequest.InsuranceQuoteRequestDto.
Entity PolicyManagement_insurance_quote_requests_InsuranceQuoteRequestDto {
String policyId
List<RequestStatusChangeDto> statusHistory
CustomerInfoDto customerInfo
InsuranceOptionsDto insuranceOptions
Date date
InsuranceQuoteDto insuranceQuote
Long id
}
}
// This Aggregate has been created on the basis of the Spring REST controller com.lakesidemutual.policymanagement.interfaces.PolicyInformationHolder.
Aggregate policies {
// This entity has been derived from the class com.lakesidemutual.policymanagement.domain.policy.PolicyId.
Entity PolicyId {
long serialVersionUID
String id
}
// This entity has been derived from the class com.lakesidemutual.policymanagement.interfaces.dtos.policy.PolicyDto.
Entity PolicyDto {
List<Link> links
PolicyPeriodDto policyPeriod
String policyId
MoneyAmountDto policyLimit
List<String> expandable
Object customer
Date creationDate
InsuringAgreementDto insuringAgreement
String policyType
MoneyAmountDto deductible
MoneyAmountDto insurancePremium
}
// This entity has been derived from the class com.lakesidemutual.policymanagement.interfaces.dtos.policy.CreatePolicyRequestDto.
Entity CreatePolicyRequestDto {
MoneyAmountDto insurancePremium
InsuringAgreementDto insuringAgreement
MoneyAmountDto policyLimit
PolicyPeriodDto policyPeriod
String customerId
String policyType
MoneyAmountDto deductible
}
// This entity has been derived from the class com.lakesidemutual.policymanagement.interfaces.dtos.policy.PaginatedPolicyResponseDto.
Entity PaginatedPolicyResponseDto {
int limit
List<Link> links
int offset
int ^size
- List<PolicyDto> policies
}
}
// This Aggregate has been created on the basis of the Spring REST controller com.lakesidemutual.policymanagement.interfaces.CustomerInformationHolder.
Aggregate PolicyManagement_customers {
// This entity has been derived from the class com.lakesidemutual.policymanagement.interfaces.dtos.customer.CustomerIdDto.
Entity CustomerIdDto {
String id
}
// This entity has been derived from the class com.lakesidemutual.policymanagement.interfaces.dtos.customer.PaginatedCustomerResponseDto.
Entity PolicyManagement_customers_PaginatedCustomerResponseDto {
int offset
int ^size
String filter
int limit
List<Link> links
- List<PolicyManagement_customers_CustomerDto> customers
}
// This entity has been derived from the class com.lakesidemutual.policymanagement.interfaces.dtos.customer.CustomerDto.
Entity PolicyManagement_customers_CustomerDto {
CustomerProfileDto customerProfile
String customerId
List<Link> links
}
}
}

BoundedContext CustomerManagement {
implementationTechnology "Spring Boot"
// This Aggregate has been created on the basis of the Spring REST controller com.lakesidemutual.customermanagement.interfaces.CustomerInformationHolder.
Aggregate CustomerManagement_customers {
// This entity has been derived from the class com.lakesidemutual.customermanagement.interfaces.dtos.CustomerDto.
Entity CustomerManagement_customers_CustomerDto {
String customerId
List<Link> links
- CustomerProfileDto customerProfile
}
// This entity has been derived from the class com.lakesidemutual.customermanagement.interfaces.dtos.CustomerProfileDto.
Entity CustomerProfileDto {
Date birthday
List<AddressDto> moveHistory
String firstname
AddressDto currentAddress
String phoneNumber
String lastname
String ^email
}
// This entity has been derived from the class com.lakesidemutual.customermanagement.interfaces.dtos.PaginatedCustomerResponseDto.
Entity CustomerManagement_customers_PaginatedCustomerResponseDto {
int offset
int ^size
String filter
int limit
List<Link> links
- List<CustomerManagement_customers_CustomerDto> customers
}
// This entity has been derived from the class com.lakesidemutual.customermanagement.domain.customer.CustomerId.
Entity CustomerManagement_customers_CustomerId {
long serialVersionUID
String id
}
}
// This Aggregate has been created on the basis of the Spring REST controller com.lakesidemutual.customermanagement.interfaces.InteractionLogInformationHolder.
Aggregate interaction_logs {
// This entity has been derived from the class com.lakesidemutual.customermanagement.domain.interactionlog.InteractionLogAggregateRoot.
Entity InteractionLogAggregateRoot {
Collection<InteractionEntity> interactions
String lastAcknowledgedInteractionId
String customerId
String username
}
// This entity has been derived from the class com.lakesidemutual.customermanagement.domain.customer.CustomerId.
Entity interaction_logs_CustomerId
}
// This Aggregate has been created on the basis of the Spring REST controller com.lakesidemutual.customermanagement.interfaces.NotificationInformationHolder.
Aggregate notifications
}

BoundedContext CustomerSelfService {
implementationTechnology "Spring Boot"
// This Aggregate has been created on the basis of the Spring REST controller com.lakesidemutual.customerselfservice.interfaces.AuthenticationController.
Aggregate auth
// This Aggregate has been created on the basis of the Spring REST controller com.lakesidemutual.customerselfservice.interfaces.CityStaticDataHolder.
Aggregate cities {
// This entity has been derived from the class com.lakesidemutual.customerselfservice.interfaces.dtos.city.CitiesResponseDto.
Entity CitiesResponseDto {
List<String> cities
}
}
// This Aggregate has been created on the basis of the Spring REST controller com.lakesidemutual.customerselfservice.interfaces.InsuranceQuoteRequestInformationHolder.
Aggregate insurance_quote_requests {
// This entity has been derived from the class com.lakesidemutual.customerselfservice.interfaces.dtos.insurancequoterequest.InsuranceQuoteRequestDto.
Entity InsuranceQuoteRequestDto {
InsuranceQuoteDto insuranceQuote
Long id
String policyId
List<RequestStatusChangeDto> statusHistory
Date date
InsuranceOptionsDto insuranceOptions
CustomerInfoDto customerInfo
}
}
// This Aggregate has been created on the basis of the Spring REST controller com.lakesidemutual.customerselfservice.interfaces.CustomerInformationHolder.
Aggregate customers {
// This entity has been derived from the class com.lakesidemutual.customerselfservice.interfaces.dtos.customer.AddressDto.
Entity AddressDto {
String city
String postalCode
String streetAddress
}
// This entity has been derived from the class com.lakesidemutual.customerselfservice.interfaces.dtos.customer.CustomerDto.
Entity CustomerDto {
CustomerProfileDto customerProfile
List<Link> links
String customerId
}
// This entity has been derived from the class com.lakesidemutual.customerselfservice.domain.customer.CustomerId.
Entity CustomerId {
long serialVersionUID
String id
}
}
// This Aggregate has been created on the basis of the Spring REST controller com.lakesidemutual.customerselfservice.interfaces.UserInformationHolder.
Aggregate user {
// This entity has been derived from the class com.lakesidemutual.customerselfservice.interfaces.dtos.identityaccess.UserResponseDto.
Entity UserResponseDto {
String customerId
String ^email
}
}
}

BoundedContext CustomerCore {
implementationTechnology "Spring Boot"
// This Aggregate has been created on the basis of the Spring REST controller com.lakesidemutual.customercore.interfaces.CityStaticDataHolder.
Aggregate CustomerCore_cities {
// This entity has been derived from the class com.lakesidemutual.customercore.interfaces.dtos.city.CitiesResponseDto.
Entity CustomerCore_cities_CitiesResponseDto {
List<String> cities
}
}
// This Aggregate has been created on the basis of the Spring REST controller com.lakesidemutual.customercore.interfaces.CustomerInformationHolder.
Aggregate CustomerCore_customers {
// This entity has been derived from the class com.lakesidemutual.customercore.interfaces.dtos.customer.CustomerResponseDto.
Entity CustomerResponseDto {
Collection<Address> moveHistory
String firstname
String lastname
String city
List<Link> links
String phoneNumber
Date birthday
String postalCode
String customerId
String ^email
String streetAddress
}
// This entity has been derived from the class com.lakesidemutual.customercore.interfaces.dtos.customer.CustomerProfileUpdateRequestDto.
Entity CustomerProfileUpdateRequestDto {
String ^email
String postalCode
String streetAddress
String firstname
String phoneNumber
String lastname
Date birthday
String city
}
// This entity has been derived from the class com.lakesidemutual.customercore.interfaces.dtos.customer.CustomersResponseDto.
Entity CustomersResponseDto {
List<Link> links
- List<CustomerResponseDto> customers
}
// This entity has been derived from the class com.lakesidemutual.customercore.interfaces.dtos.customer.AddressDto.
Entity CustomerCore_customers_AddressDto {
String city
String postalCode
String streetAddress
}
// This entity has been derived from the class com.lakesidemutual.customercore.interfaces.dtos.customer.PaginatedCustomerResponseDto.
Entity PaginatedCustomerResponseDto {
int ^size
int offset
List<Link> links
int limit
String filter
- List<CustomerResponseDto> customers
}
// This entity has been derived from the class com.lakesidemutual.customercore.domain.customer.CustomerId.
Entity CustomerCore_customers_CustomerId {
String id
long serialVersionUID
}
}
}

14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ if (!project.hasProperty('signing.secretKeyRingFile')) {
}

dependencies {
implementation 'org.reflections:reflections:0.9.11'
implementation 'org.springframework.boot:spring-boot-autoconfigure:2.2.0.RELEASE'
implementation 'org.springframework:spring-web:5.2.0.RELEASE'
implementation 'org.apache.commons:commons-lang3:3.9'
implementation 'commons-io:commons-io:2.6'
implementation 'org.yaml:snakeyaml:1.25'
implementation 'org.contextmapper:context-mapper-dsl:5.1.0'
implementation "org.reflections:reflections:${reflectionsVersion}"
implementation "org.springframework.boot:spring-boot-autoconfigure:${springBootVersion}"
implementation "org.springframework:spring-web:${springWebVersion}"
implementation "org.apache.commons:commons-lang3:${commonsLangVersion}"
implementation "commons-io:commons-io:${commonsIOVersion}"
implementation "org.yaml:snakeyaml:${snakeYMLVersion}"
implementation "org.contextmapper:context-mapper-dsl:${cmlVersion}"

testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: jUnitVersion
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: jUnitVersion
Expand Down
7 changes: 7 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@ ossReleaseStagingRepository=https://oss.sonatype.org/service/local/staging/deplo

# dependency versions
jUnitVersion=5.5.2
cmlVersion=5.2.0
reflectionsVersion=0.9.11
springBootVersion=2.2.0.RELEASE
springWebVersion=5.2.0.RELEASE
commonsLangVersion=3.9
commonsIOVersion=2.6
snakeYMLVersion=1.25
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ private BoundedContext convert(org.contextmapper.discovery.model.BoundedContext
private Aggregate convert(org.contextmapper.discovery.model.Aggregate inputAggregate) {
Aggregate aggregate = ContextMappingDSLFactory.eINSTANCE.createAggregate();
aggregate.setName(inputAggregate.getName());
aggregate.setComment("// " + inputAggregate.getDiscoveryComment());
for (org.contextmapper.discovery.model.Entity entity : inputAggregate.getEntities()) {
aggregate.getDomainObjects().add(convert(entity));
}
Expand All @@ -80,6 +81,7 @@ private Aggregate convert(org.contextmapper.discovery.model.Aggregate inputAggre
private Entity convert(org.contextmapper.discovery.model.Entity inputEntity) {
Entity entity = TacticdslFactory.eINSTANCE.createEntity();
entity.setName(inputEntity.getName());
entity.setComment("// " + inputEntity.getDiscoveryComment());
entityLookupMap.put(inputEntity, entity);
return entity;
}
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/org/contextmapper/discovery/model/Aggregate.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class Aggregate {

private String name;
private Set<Entity> entities;
private String discoveryComment;

public Aggregate(String name) {
setName(name);
Expand Down Expand Up @@ -83,6 +84,24 @@ public Set<Entity> getEntities() {
return new HashSet<>(entities);
}

/**
* Sets a comment regarding how the Aggregate has been discovered.
*
* @param discoveryComment the comment regarding how the Aggregate has been discovered
*/
public void setDiscoveryComment(String discoveryComment) {
this.discoveryComment = discoveryComment;
}

/**
* Gets a comment regarding how the Aggregate has been discovered.
*
* @return a comment regarding how the Aggregate has been discovered.
*/
public String getDiscoveryComment() {
return discoveryComment;
}

@Override
public boolean equals(Object object) {
if (!(object instanceof Aggregate))
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/org/contextmapper/discovery/model/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class Entity {
private String type;
private Set<Attribute> attributes;
private Set<Reference> references;
private String discoveryComment;

public Entity(String type, String name) {
if (name == null || "".equals(name))
Expand Down Expand Up @@ -101,6 +102,24 @@ public Set<Reference> getReferences() {
return new HashSet<>(references);
}

/**
* Sets a comment describing how the entity has been discovered.
*
* @param discoveryComment the comment describing how the entity has been discovered
*/
public void setDiscoveryComment(String discoveryComment) {
this.discoveryComment = discoveryComment;
}

/**
* Gets a comment describing how the entity has been discovered.
*
* @return the comment describing how the entity has been discovered
*/
public String getDiscoveryComment() {
return discoveryComment;
}

@Override
public boolean equals(Object object) {
if (!(object instanceof Entity))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ private Set<Aggregate> discoverAggregates(BoundedContext bc, String packageName)
if (requestMapping.value().length > 0) {
Aggregate aggregate = createAggregate(bc, requestMapping.value()[0]);
aggregate.addEntities(discoverEntities(aggregate.getName(), type));
aggregate.setDiscoveryComment("This Aggregate has been created on the basis of the Spring REST controller " + type.getName() + ".");
resultSet.add(aggregate);
}
}
Expand Down Expand Up @@ -129,6 +130,7 @@ private Entity createEntityFromType(String aggregateName, Class<?> type) {
}
this.discoveredEntityNames.add(entityName);
Entity entity = new Entity(type.getName(), entityName);
entity.setDiscoveryComment("This entity has been derived from the class " + type.getName() + ".");
this.entityMap.put(type, entity);
return entity;
}
Expand Down
Loading

0 comments on commit 27c1982

Please sign in to comment.