Search in sources :

Example 1 with TicketsHandler

use of org.ndx.agile.architecture.base.enhancers.tickets.TicketsHandler 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 TicketsHandler

use of org.ndx.agile.architecture.base.enhancers.tickets.TicketsHandler 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

Element (com.structurizr.model.Element)2 StaticStructureElement (com.structurizr.model.StaticStructureElement)2 Template (freemarker.template.Template)2 TemplateException (freemarker.template.TemplateException)2 File (java.io.File)2 FileWriter (java.io.FileWriter)2 IOException (java.io.IOException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Collection (java.util.Collection)2 Comparator (java.util.Comparator)2 Date (java.util.Date)2 Map (java.util.Map)2 Optional (java.util.Optional)2 Function (java.util.function.Function)2 Logger (java.util.logging.Logger)2 Collectors (java.util.stream.Collectors)2 ApplicationScoped (javax.enterprise.context.ApplicationScoped)2 Instance (javax.enterprise.inject.Instance)2 Inject (javax.inject.Inject)2 ConfigProperty (org.apache.deltaspike.core.api.config.ConfigProperty)2