Search in sources :

Example 1 with OutputBuilder

use of org.ndx.agile.architecture.base.OutputBuilder in project agile-architecture-documentation-system by Riduidel.

the class ADRExtractor method writeArchitectureDecisionsUsing.

private void writeArchitectureDecisionsUsing(Element element, String project, String label, TicketsHandler handler, OutputBuilder builder) {
    File output = builder.outputFor(AgileArchitectureSection.decision_log, element, this, "adoc");
    if (force) {
        output.delete();
    }
    Collection<Ticket> tickets = handler.getTicketsTagged(project, label);
    // Write each decision
    Map<Ticket, String> ticketsTexts = tickets.stream().sorted(new ByStatusThenDate()).collect(Collectors.toMap(Function.identity(), t -> writeArchitectureDecisionTicket(builder, element, t)));
    try {
        try (FileWriter writer = new FileWriter(output)) {
            decisionList.process(new IndexModel(handler.getIssuesUrl(project), handler.getProjectName(project), label, ticketsTexts), writer);
        }
    } catch (IOException | TemplateException e) {
        throw new UnableToCreateDecisionLog(String.format("Can't write decision log index to file %s", output), e);
    }
// Make sure the decision record uses that index
}
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) Ticket(org.ndx.agile.architecture.base.enhancers.tickets.Ticket) TemplateException(freemarker.template.TemplateException) FileWriter(java.io.FileWriter) IOException(java.io.IOException) File(java.io.File)

Example 2 with OutputBuilder

use of org.ndx.agile.architecture.base.OutputBuilder 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)

Example 3 with OutputBuilder

use of org.ndx.agile.architecture.base.OutputBuilder in project agile-architecture-documentation-system by Riduidel.

the class DocumentsCollector method collect.

/**
 * Collect elements of all sections produced for the given component
 * @param element the element for which we want the output
 * @param builder output generator used
 */
public void collect(Element element, OutputBuilder builder) {
    for (AgileArchitectureSection section : AgileArchitectureSection.values()) {
        File sectionFolderFor = builder.outputDirectoryFor(section, element);
        File[] filesArray = sectionFolderFor.listFiles((dir, name) -> name.toLowerCase().endsWith(".adoc"));
        if (filesArray != null && filesArray.length > 0) {
            Set<File> files = Stream.of(filesArray).map(file -> file.getAbsoluteFile()).collect(Collectors.toCollection(() -> new TreeSet<File>()));
            hierarchy.get(section).put(element, files);
        }
    }
}
Also used : Arrays(java.util.Arrays) OutputBuilder(org.ndx.agile.architecture.base.OutputBuilder) StringUtils(org.apache.commons.lang3.StringUtils) Component(com.structurizr.model.Component) TreeSet(java.util.TreeSet) ConfigProperty(org.apache.deltaspike.core.api.config.ConfigProperty) ModelElementKeys(org.ndx.agile.architecture.base.enhancers.ModelElementKeys) Inject(javax.inject.Inject) StructurizrUtils(org.ndx.agile.architecture.base.utils.StructurizrUtils) Map(java.util.Map) Model(com.structurizr.model.Model) Container(com.structurizr.model.Container) EnumMap(java.util.EnumMap) Set(java.util.Set) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) ModelEnhancer(org.ndx.agile.architecture.base.ModelEnhancer) SoftwareSystem(com.structurizr.model.SoftwareSystem) AgileArchitectureSection(org.ndx.agile.architecture.base.AgileArchitectureSection) Collectors(java.util.stream.Collectors) File(java.io.File) Workspace(com.structurizr.Workspace) Stream(java.util.stream.Stream) TreeMap(java.util.TreeMap) Comparator(java.util.Comparator) Element(com.structurizr.model.Element) TreeSet(java.util.TreeSet) AgileArchitectureSection(org.ndx.agile.architecture.base.AgileArchitectureSection) File(java.io.File)

Aggregations

Element (com.structurizr.model.Element)3 File (java.io.File)3 IOException (java.io.IOException)3 Comparator (java.util.Comparator)3 Map (java.util.Map)3 Collectors (java.util.stream.Collectors)3 Inject (javax.inject.Inject)3 ConfigProperty (org.apache.deltaspike.core.api.config.ConfigProperty)3 AgileArchitectureSection (org.ndx.agile.architecture.base.AgileArchitectureSection)3 OutputBuilder (org.ndx.agile.architecture.base.OutputBuilder)3 ModelElementKeys (org.ndx.agile.architecture.base.enhancers.ModelElementKeys)3 StaticStructureElement (com.structurizr.model.StaticStructureElement)2 Template (freemarker.template.Template)2 TemplateException (freemarker.template.TemplateException)2 FileWriter (java.io.FileWriter)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Collection (java.util.Collection)2 Date (java.util.Date)2 Optional (java.util.Optional)2 Function (java.util.function.Function)2