use of com.structurizr.model.Element in project java by structurizr.
the class ElementViewTests method test_copyLayoutInformationFrom_CopiesXAndY_WhenANonNullElementViewIsPassed.
@Test
public void test_copyLayoutInformationFrom_CopiesXAndY_WhenANonNullElementViewIsPassed() {
Element element = model.addSoftwareSystem(Location.External, "SystemA", "");
ElementView elementView1 = new ElementView(element);
assertEquals(0, elementView1.getX());
assertEquals(0, elementView1.getY());
ElementView elementView2 = new ElementView(element);
elementView2.setX(123);
elementView2.setY(456);
elementView1.copyLayoutInformationFrom(elementView2);
assertEquals(123, elementView1.getX());
assertEquals(456, elementView1.getY());
}
use of com.structurizr.model.Element in project java by structurizr.
the class CustomView method addAnimation.
/**
* Adds an animation step, with the specified elements.
*
* @param elements the elements that should be shown in the animation step
*/
public void addAnimation(CustomElement... elements) {
if (elements == null || elements.length == 0) {
throw new IllegalArgumentException("One or more elements must be specified.");
}
Set<String> elementIdsInPreviousAnimationSteps = new HashSet<>();
for (Animation animationStep : animations) {
elementIdsInPreviousAnimationSteps.addAll(animationStep.getElements());
}
Set<Element> elementsInThisAnimationStep = new HashSet<>();
Set<Relationship> relationshipsInThisAnimationStep = new HashSet<>();
for (CustomElement element : elements) {
if (isElementInView(element)) {
if (!elementIdsInPreviousAnimationSteps.contains(element.getId())) {
elementIdsInPreviousAnimationSteps.add(element.getId());
elementsInThisAnimationStep.add(element);
}
}
}
if (elementsInThisAnimationStep.size() == 0) {
throw new IllegalArgumentException("None of the specified elements exist in this view.");
}
for (RelationshipView relationshipView : this.getRelationships()) {
if ((elementsInThisAnimationStep.contains(relationshipView.getRelationship().getSource()) && elementIdsInPreviousAnimationSteps.contains(relationshipView.getRelationship().getDestination().getId())) || (elementIdsInPreviousAnimationSteps.contains(relationshipView.getRelationship().getSource().getId()) && elementsInThisAnimationStep.contains(relationshipView.getRelationship().getDestination()))) {
relationshipsInThisAnimationStep.add(relationshipView.getRelationship());
}
}
animations.add(new Animation(animations.size() + 1, elementsInThisAnimationStep, relationshipsInThisAnimationStep));
}
use of com.structurizr.model.Element in project java by structurizr.
the class DefaultLayoutMergeStrategy method findRelationshipView.
private RelationshipView findRelationshipView(View viewWithLayoutInformation, Relationship relationshipWithoutLayoutInformation, Map<Element, Element> elementMap) {
if (!elementMap.containsKey(relationshipWithoutLayoutInformation.getSource()) || !elementMap.containsKey(relationshipWithoutLayoutInformation.getDestination())) {
return null;
}
Element sourceElementWithLayoutInformation = elementMap.get(relationshipWithoutLayoutInformation.getSource());
Element destinationElementWithLayoutInformation = elementMap.get(relationshipWithoutLayoutInformation.getDestination());
for (RelationshipView rv : viewWithLayoutInformation.getRelationships()) {
if (rv.getRelationship().getSource().equals(sourceElementWithLayoutInformation) && rv.getRelationship().getDestination().equals(destinationElementWithLayoutInformation) && rv.getRelationship().getDescription().equals(relationshipWithoutLayoutInformation.getDescription())) {
return rv;
}
}
return null;
}
use of com.structurizr.model.Element 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
}
use of com.structurizr.model.Element 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