use of com.structurizr.model.StaticStructureElement in project dsl by structurizr.
the class DynamicViewContentParser method parseRelationship.
void parseRelationship(DynamicViewDslContext context, Tokens tokens) {
// <identifier> -> <identifier> [description] [technology]
DynamicView view = context.getView();
if (tokens.hasMoreThan(TECHNOLOGY_INDEX)) {
throw new RuntimeException("Too many tokens, expected: " + GRAMMAR);
}
if (!tokens.includes(DESTINATION_IDENTIFIER_INDEX)) {
throw new RuntimeException("Expected: " + GRAMMAR);
}
String sourceId = tokens.get(SOURCE_IDENTIFIER_INDEX);
String destinationId = tokens.get(DESTINATION_IDENTIFIER_INDEX);
Element sourceElement = context.getElement(sourceId);
if (sourceElement == null) {
throw new RuntimeException("The source element \"" + sourceId + "\" does not exist");
}
if (!(sourceElement instanceof StaticStructureElement)) {
throw new RuntimeException("The source element \"" + sourceId + "\" should be a static structure element");
}
Element destinationElement = context.getElement(destinationId);
if (destinationElement == null) {
throw new RuntimeException("The destination element \"" + destinationId + "\" does not exist");
}
if (!(destinationElement instanceof StaticStructureElement)) {
throw new RuntimeException("The destination element \"" + destinationId + "\" should be a static structure element");
}
String description = "";
if (tokens.includes(DESCRIPTION_INDEX)) {
description = tokens.get(DESCRIPTION_INDEX);
}
String technology = "";
if (tokens.includes(TECHNOLOGY_INDEX)) {
technology = tokens.get(TECHNOLOGY_INDEX);
}
if (!sourceElement.hasEfferentRelationshipWith(destinationElement) && !destinationElement.hasEfferentRelationshipWith(sourceElement)) {
new ExplicitRelationshipParser().parse(context, tokens);
}
view.add((StaticStructureElement) sourceElement, description, technology, (StaticStructureElement) destinationElement);
}
use of com.structurizr.model.StaticStructureElement in project agile-architecture-documentation-system by Riduidel.
the class AddDependenciesFromProperties method addDependencyFromProperties.
private void addDependencyFromProperties(StaticStructureElement element, Element dependency, String dependencyDescription) {
if (dependency instanceof StaticStructureElement) {
StaticStructureElement structureElement = (StaticStructureElement) dependency;
element.uses(structureElement, dependencyDescription, "", InteractionStyle.Synchronous);
}
}
use of com.structurizr.model.StaticStructureElement in project agile-architecture-documentation-system by Riduidel.
the class ADRExtractor method processElement.
@Override
protected void processElement(StaticStructureElement element, OutputBuilder builder) {
if (element.getProperties().containsKey(AGILE_ARCHITECTURE_TICKETS_PROJECT)) {
String ticketsProject = element.getProperties().get(AGILE_ARCHITECTURE_TICKETS_PROJECT);
Optional<TicketsHandler> usableHandler = ticketsHandlers.stream().filter(handler -> handler.canHandle(ticketsProject)).findFirst();
if (usableHandler.isPresent()) {
String label = element.getProperties().getOrDefault(AGILE_ARCHITECTURE_TICKETS_ADR_LABEL, "decision");
TicketsHandler handler = usableHandler.get();
writeArchitectureDecisionsUsing(element, ticketsProject, label, handler, builder);
} else {
logger.warning(String.format("We have this set of handlers\n%s\nin which we couldn't find one for tickets project %s", ticketsHandlers.stream().map(handler -> handler.toString()).collect(Collectors.joining()), ticketsProject));
}
}
}
Aggregations