use of org.contextmapper.dsl.refactoring.exception.RefactoringInputException in project context-mapper-dsl by ContextMapper.
the class DeriveSubdomainFromUserRequirements method doRefactor.
@Override
protected void doRefactor() {
Set<UserRequirement> selectedUserRequirements = collectUserRequirements();
// if there are no user stories or use cases selected, we do nothing
if (selectedUserRequirements.isEmpty())
throw new RefactoringInputException("Please provide at least one user story or use case that exists in the CML model.");
Domain domain = getOrCreateDomain();
Subdomain subdomain = getOrCreateSubdomain(domain);
addElementsToEList(subdomain.getSupportedFeatures(), Lists.newLinkedList(selectedUserRequirements));
List<String> benefits = Lists.newLinkedList();
if (subdomain.getDomainVisionStatement() != null && !"".equals(subdomain.getDomainVisionStatement()))
benefits.addAll(Arrays.asList(subdomain.getDomainVisionStatement().split(BENEFIT_SEPARATOR_STRING)));
for (UserRequirement ur : selectedUserRequirements) {
if (!doesContainAtLeastOneEntity(ur))
continue;
benefits.add("Aims at promoting the following benefit for a " + ur.getRole() + ": " + ur.getBenefit());
deriveSubdomainEntities4Features(subdomain, ur.getName(), ur.getFeatures());
}
for (UserRequirement ur : selectedUserRequirements) {
deriveSubdomainEntityReferences(subdomain, ur.getFeatures());
}
subdomain.setDomainVisionStatement(String.join(BENEFIT_SEPARATOR_STRING, benefits));
}
use of org.contextmapper.dsl.refactoring.exception.RefactoringInputException in project context-mapper-dsl by ContextMapper.
the class DeriveSubdomainFromUserRequirements method getOrCreateDomain.
private Domain getOrCreateDomain() {
if (domainName == null || "".equals(domainName))
throw new RefactoringInputException("Please provide a name for the domain where the new subdomain shall be added.");
Optional<Domain> optDomain = getAllDomains().stream().filter(d -> domainName.equals(d.getName())).findFirst();
if (optDomain.isPresent())
return optDomain.get();
Domain newDomain = ContextMappingDSLFactory.eINSTANCE.createDomain();
newDomain.setName(domainName);
addElementToEList(model.getDomains(), newDomain);
return newDomain;
}
use of org.contextmapper.dsl.refactoring.exception.RefactoringInputException in project context-mapper-dsl by ContextMapper.
the class DeriveSubdomainFromUserRequirements method getOrCreateSubdomain.
private Subdomain getOrCreateSubdomain(Domain domain) {
if (subdomainName == null || "".equals(subdomainName))
throw new RefactoringInputException("Please provide a name for the subdomain that shall be created or existing subdomain that shall contain the new entities.");
Optional<Subdomain> optSubdomain = domain.getSubdomains().stream().filter(sd -> subdomainName.equals(sd.getName())).findFirst();
if (optSubdomain.isPresent())
return optSubdomain.get();
Subdomain newSubdomain = ContextMappingDSLFactory.eINSTANCE.createSubdomain();
newSubdomain.setName(subdomainName);
addElementToEList(domain.getSubdomains(), newSubdomain);
return newSubdomain;
}
use of org.contextmapper.dsl.refactoring.exception.RefactoringInputException in project context-mapper-dsl by ContextMapper.
the class MergeAggregatesRefactoring method checkForPossibleDomainObjectNameClashes.
private void checkForPossibleDomainObjectNameClashes(Aggregate aggregate1, Aggregate aggregate2) {
List<String> aggregate1DomainObjectNames = aggregate1.getDomainObjects().stream().map(obj -> obj.getName()).collect(Collectors.toList());
List<String> aggregate2DomainObjectNames = aggregate2.getDomainObjects().stream().map(obj -> obj.getName()).collect(Collectors.toList());
Set<String> commonDomainObjectNames = aggregate1DomainObjectNames.stream().distinct().filter(aggregate2DomainObjectNames::contains).collect(Collectors.toSet());
if (!commonDomainObjectNames.isEmpty())
throw new RefactoringInputException("Sorry, we cannot execute this refactoring. The selected Aggregates contain the following duplicate domain objects: " + String.join(", ", commonDomainObjectNames));
}
use of org.contextmapper.dsl.refactoring.exception.RefactoringInputException in project context-mapper-dsl by ContextMapper.
the class DeriveBoundedContextFromSubdomains method doRefactor.
@Override
protected void doRefactor() {
Set<Subdomain> selectedSubdomains = collectSubdomains();
if (selectedSubdomains.isEmpty())
throw new RefactoringInputException("Please provide at least one subdomain name that can be found in the given CML model.");
BoundedContext bc = createOrGetBoundedContext(boundedContextName);
bc.setDomainVisionStatement("This Bounded Context realizes the following subdomains: " + String.join(", ", selectedSubdomains.stream().map(sd -> sd.getName()).collect(Collectors.toList())));
bc.setType(BoundedContextType.FEATURE);
for (Subdomain subdomain : selectedSubdomains) {
addElementToEList(bc.getImplementedDomainParts(), (DomainPart) subdomain);
createAggregate4Subdomain(subdomain, bc);
}
}
Aggregations