Search in sources :

Example 1 with StaticStructureElement

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);
}
Also used : StaticStructureElement(com.structurizr.model.StaticStructureElement) StaticStructureElement(com.structurizr.model.StaticStructureElement) Element(com.structurizr.model.Element) DynamicView(com.structurizr.view.DynamicView)

Example 2 with StaticStructureElement

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);
    }
}
Also used : StaticStructureElement(com.structurizr.model.StaticStructureElement)

Example 3 with StaticStructureElement

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));
        }
    }
}
Also used : Date(java.util.Date) TemplateException(freemarker.template.TemplateException) OutputBuilder(org.ndx.agile.architecture.base.OutputBuilder) SimpleDateFormat(java.text.SimpleDateFormat) ModelElementAdapter(org.ndx.agile.architecture.base.enhancers.ModelElementAdapter) Function(java.util.function.Function) ConfigProperty(org.apache.deltaspike.core.api.config.ConfigProperty) ModelElementKeys(org.ndx.agile.architecture.base.enhancers.ModelElementKeys) Inject(javax.inject.Inject) Map(java.util.Map) Template(freemarker.template.Template) StaticStructureElement(com.structurizr.model.StaticStructureElement) Instance(javax.enterprise.inject.Instance) TicketStatus(org.ndx.agile.architecture.base.enhancers.tickets.TicketStatus) Ticket(org.ndx.agile.architecture.base.enhancers.tickets.Ticket) Collection(java.util.Collection) FileWriter(java.io.FileWriter) IOException(java.io.IOException) AgileArchitectureSection(org.ndx.agile.architecture.base.AgileArchitectureSection) Enhancer(org.ndx.agile.architecture.base.Enhancer) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) File(java.io.File) Optional(java.util.Optional) ApplicationScoped(javax.enterprise.context.ApplicationScoped) Comparator(java.util.Comparator) TicketsHandler(org.ndx.agile.architecture.base.enhancers.tickets.TicketsHandler) Element(com.structurizr.model.Element) TicketsHandler(org.ndx.agile.architecture.base.enhancers.tickets.TicketsHandler)

Aggregations

StaticStructureElement (com.structurizr.model.StaticStructureElement)3 Element (com.structurizr.model.Element)2 DynamicView (com.structurizr.view.DynamicView)1 Template (freemarker.template.Template)1 TemplateException (freemarker.template.TemplateException)1 File (java.io.File)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Collection (java.util.Collection)1 Comparator (java.util.Comparator)1 Date (java.util.Date)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Function (java.util.function.Function)1 Logger (java.util.logging.Logger)1 Collectors (java.util.stream.Collectors)1 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Instance (javax.enterprise.inject.Instance)1 Inject (javax.inject.Inject)1