Java源码示例:com.structurizr.model.Person
示例1
public static void main(String[] args) throws Exception {
Workspace workspace = new Workspace("Documentation - Automatic", "An empty software architecture document using the Structurizr template.");
Model model = workspace.getModel();
ViewSet views = workspace.getViews();
Person user = model.addPerson("User", "A user of my software system.");
SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "My software system.");
user.uses(softwareSystem, "Uses");
SystemContextView contextView = views.createSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram.");
contextView.addAllSoftwareSystems();
contextView.addAllPeople();
Styles styles = views.getConfiguration().getStyles();
styles.addElementStyle(Tags.PERSON).shape(Shape.Person);
// this directory includes a mix of Markdown and AsciiDoc files
File documentationRoot = new File("./structurizr-examples/src/com/structurizr/example/documentation/automatic");
AutomaticDocumentationTemplate template = new AutomaticDocumentationTemplate(workspace);
template.addSections(softwareSystem, documentationRoot);
StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
}
示例2
public static void main(String[] args) throws Exception {
Workspace workspace = new Workspace("Theme", "This is a model of my software system.");
Model model = workspace.getModel();
Person user = model.addPerson("User", "A user of my software system.");
SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "My software system.");
user.uses(softwareSystem, "Uses");
ViewSet views = workspace.getViews();
SystemContextView contextView = views.createSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram.");
contextView.addAllSoftwareSystems();
contextView.addAllPeople();
// add a theme
views.getConfiguration().setTheme("https://raw.githubusercontent.com/structurizr/java/master/structurizr-examples/src/com/structurizr/example/theme/theme.json");
StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
}
示例3
public static void main(String[] args) throws Exception {
Workspace workspace = new Workspace("Corporate Branding", "This is a model of my software system.");
Model model = workspace.getModel();
Person user = model.addPerson("User", "A user of my software system.");
SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "My software system.");
user.uses(softwareSystem, "Uses");
ViewSet views = workspace.getViews();
SystemContextView contextView = views.createSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram.");
contextView.addAllSoftwareSystems();
contextView.addAllPeople();
Styles styles = views.getConfiguration().getStyles();
styles.addElementStyle(Tags.PERSON).shape(Shape.Person);
StructurizrDocumentationTemplate template = new StructurizrDocumentationTemplate(workspace);
template.addContextSection(softwareSystem, Format.Markdown, "Here is some context about the software system...\n\n");
Branding branding = views.getConfiguration().getBranding();
branding.setLogo(ImageUtils.getImageAsDataUri(new File("./docs/images/structurizr-logo.png")));
StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
}
示例4
public static void main(String[] args) throws Exception {
Workspace workspace = new Workspace("Client-side encrypted workspace", "This is a client-side encrypted workspace. The passphrase is 'password'.");
Model model = workspace.getModel();
Person user = model.addPerson("User", "A user of my software system.");
SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "My software system.");
user.uses(softwareSystem, "Uses");
ViewSet views = workspace.getViews();
SystemContextView contextView = views.createSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram.");
contextView.addAllSoftwareSystems();
contextView.addAllPeople();
Styles styles = views.getConfiguration().getStyles();
styles.addElementStyle(Tags.SOFTWARE_SYSTEM).background("#d34407").color("#ffffff");
styles.addElementStyle(Tags.PERSON).background("#f86628").color("#ffffff").shape(Shape.Person);
StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
structurizrClient.setEncryptionStrategy(new AesEncryptionStrategy("password"));
structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
}
示例5
public static void main(String[] args) throws Exception {
// all software architecture models belong to a workspace
Workspace workspace = new Workspace("Getting Started", "This is a model of my software system.");
Model model = workspace.getModel();
// create a model to describe a user using a software system
Person user = model.addPerson("User", "A user of my software system.");
SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "My software system.");
user.uses(softwareSystem, "Uses");
// create a system context diagram showing people and software systems
ViewSet views = workspace.getViews();
SystemContextView contextView = views.createSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram.");
contextView.addAllSoftwareSystems();
contextView.addAllPeople();
// add some styling to the diagram elements
Styles styles = views.getConfiguration().getStyles();
styles.addElementStyle(Tags.SOFTWARE_SYSTEM).background("#1168bd").color("#ffffff");
styles.addElementStyle(Tags.PERSON).background("#08427b").color("#ffffff").shape(Shape.Person);
// upload to structurizr.com (you'll need your own workspace ID, API key and API secret)
StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
}
示例6
@Test
public void test_putAndGetWorkspace_WithoutEncryption() throws Exception {
Workspace workspace = new Workspace("Structurizr client library tests - without encryption", "A test workspace for the Structurizr client library");
SoftwareSystem softwareSystem = workspace.getModel().addSoftwareSystem("Software System", "Description");
Person person = workspace.getModel().addPerson("Person", "Description");
person.uses(softwareSystem, "Uses");
SystemContextView systemContextView = workspace.getViews().createSystemContextView(softwareSystem, "SystemContext", "Description");
systemContextView.addAllElements();
structurizrClient.putWorkspace(20081, workspace);
workspace = structurizrClient.getWorkspace(20081);
assertNotNull(workspace.getModel().getSoftwareSystemWithName("Software System"));
assertNotNull(workspace.getModel().getPersonWithName("Person"));
assertEquals(1, workspace.getModel().getRelationships().size());
assertEquals(1, workspace.getViews().getSystemContextViews().size());
// and check the archive version is readable
Workspace archivedWorkspace = new JsonReader().read(new FileReader(getArchivedWorkspace()));
assertEquals(20081, archivedWorkspace.getId());
assertEquals("Structurizr client library tests - without encryption", archivedWorkspace.getName());
assertEquals(1, archivedWorkspace.getModel().getSoftwareSystems().size());
assertEquals(1, workspaceArchiveLocation.listFiles().length);
}
示例7
@Test
public void test_putAndGetWorkspace_WithEncryption() throws Exception {
structurizrClient.setEncryptionStrategy(new AesEncryptionStrategy("password"));
Workspace workspace = new Workspace("Structurizr client library tests - with encryption", "A test workspace for the Structurizr client library");
SoftwareSystem softwareSystem = workspace.getModel().addSoftwareSystem("Software System", "Description");
Person person = workspace.getModel().addPerson("Person", "Description");
person.uses(softwareSystem, "Uses");
SystemContextView systemContextView = workspace.getViews().createSystemContextView(softwareSystem, "SystemContext", "Description");
systemContextView.addAllElements();
structurizrClient.putWorkspace(20081, workspace);
workspace = structurizrClient.getWorkspace(20081);
assertNotNull(workspace.getModel().getSoftwareSystemWithName("Software System"));
assertNotNull(workspace.getModel().getPersonWithName("Person"));
assertEquals(1, workspace.getModel().getRelationships().size());
assertEquals(1, workspace.getViews().getSystemContextViews().size());
// and check the archive version is readable
EncryptedWorkspace archivedWorkspace = new EncryptedJsonReader().read(new FileReader(getArchivedWorkspace()));
assertEquals(20081, archivedWorkspace.getId());
assertEquals("Structurizr client library tests - with encryption", archivedWorkspace.getName());
assertTrue(archivedWorkspace.getEncryptionStrategy() instanceof AesEncryptionStrategy);
assertEquals(1, workspaceArchiveLocation.listFiles().length);
}
示例8
private static Workspace getSoftwareSystem() {
Workspace workspace = new Workspace("Payment Gateway", "Payment Gateway");
Model model = workspace.getModel();
Person user = model.addPerson("Merchant", "Merchant");
SoftwareSystem paymentTerminal = model.addSoftwareSystem(PAYMENT_TERMINAL, "Payment Terminal");
user.uses(paymentTerminal, "Makes payment");
SoftwareSystem fraudDetector = model.addSoftwareSystem(FRAUD_DETECTOR, "Fraud Detector");
paymentTerminal.uses(fraudDetector, "Obtains fraud score");
ViewSet viewSet = workspace.getViews();
SystemContextView contextView = viewSet.createSystemContextView(workspace.getModel().getSoftwareSystemWithName(PAYMENT_TERMINAL), SOFTWARE_SYSTEM_VIEW, "Payment Gateway Diagram");
contextView.addAllElements();
return workspace;
}
示例9
public static void main(String[] args) throws Exception {
// a Structurizr workspace is the wrapper for a software architecture model, views and documentation
Workspace workspace = new Workspace("Getting Started", "This is a model of my software system.");
Model model = workspace.getModel();
// add some elements to your software architecture model
Person user = model.addPerson("User", "A user of my software system.");
SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "My software system.");
user.uses(softwareSystem, "Uses");
// define some views (the diagrams you would like to see)
ViewSet views = workspace.getViews();
SystemContextView contextView = views.createSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram.");
contextView.setPaperSize(PaperSize.A5_Landscape);
contextView.addAllSoftwareSystems();
contextView.addAllPeople();
// add some documentation
StructurizrDocumentationTemplate template = new StructurizrDocumentationTemplate(workspace);
template.addContextSection(softwareSystem, Format.Markdown,
"Here is some context about the software system...\n" +
"\n" +
"");
// add some styling
Styles styles = views.getConfiguration().getStyles();
styles.addElementStyle(Tags.SOFTWARE_SYSTEM).background("#1168bd").color("#ffffff");
styles.addElementStyle(Tags.PERSON).background("#08427b").color("#ffffff").shape(Shape.Person);
uploadWorkspaceToStructurizr(workspace);
}
示例10
public static void main(String[] args) throws Exception {
Workspace workspace = new Workspace("Styling Elements", "This is a model of my software system.");
Model model = workspace.getModel();
Person user = model.addPerson("User", "A user of my software system.");
SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "My software system.");
Container webApplication = softwareSystem.addContainer("Web Application", "My web application.", "Java and Spring MVC");
Container database = softwareSystem.addContainer("Database", "My database.", "Relational database schema");
user.uses(webApplication, "Uses", "HTTPS");
webApplication.uses(database, "Reads from and writes to", "JDBC");
ViewSet views = workspace.getViews();
ContainerView containerView = views.createContainerView(softwareSystem, "containers", "An example of a container diagram.");
containerView.addAllElements();
Styles styles = workspace.getViews().getConfiguration().getStyles();
// example 1
// styles.addElementStyle(Tags.ELEMENT).background("#438dd5").color("#ffffff");
// example 2
// styles.addElementStyle(Tags.ELEMENT).color("#ffffff");
// styles.addElementStyle(Tags.PERSON).background("#08427b");
// styles.addElementStyle(Tags.CONTAINER).background("#438dd5");
// example 3
// styles.addElementStyle(Tags.ELEMENT).color("#ffffff");
// styles.addElementStyle(Tags.PERSON).background("#08427b").shape(Shape.Person);
// styles.addElementStyle(Tags.CONTAINER).background("#438dd5");
// database.addTags("Database");
// styles.addElementStyle("Database").shape(Shape.Cylinder);
StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
}
示例11
public static void main(String[] args) throws Exception {
Workspace workspace = new Workspace("Filtered Views", "An example of using filtered views.");
Model model = workspace.getModel();
Person user = model.addPerson("User", "A description of the user.");
SoftwareSystem softwareSystemA = model.addSoftwareSystem("Software System A", "A description of software system A.");
SoftwareSystem softwareSystemB = model.addSoftwareSystem("Software System B", "A description of software system B.");
softwareSystemB.addTags(FUTURE_STATE);
user.uses(softwareSystemA, "Uses for tasks 1 and 2").addTags(CURRENT_STATE);
user.uses(softwareSystemA, "Uses for task 1").addTags(FUTURE_STATE);
user.uses(softwareSystemB, "Uses for task 2").addTags(FUTURE_STATE);
ViewSet views = workspace.getViews();
SystemLandscapeView systemLandscapeView = views.createSystemLandscapeView("SystemLandscape", "An example System Landscape diagram.");
systemLandscapeView.addAllElements();
views.createFilteredView(systemLandscapeView, "CurrentState", "The current system landscape.", FilterMode.Exclude, FUTURE_STATE);
views.createFilteredView(systemLandscapeView, "FutureState", "The future state system landscape after Software System B is live.", FilterMode.Exclude, CURRENT_STATE);
Styles styles = views.getConfiguration().getStyles();
styles.addElementStyle(Tags.ELEMENT).color("#ffffff");
styles.addElementStyle(Tags.SOFTWARE_SYSTEM).background("#91a437").shape(Shape.RoundedBox);
styles.addElementStyle(Tags.PERSON).background("#6a7b15").shape(Shape.Person);
StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
}
示例12
public static void main(String[] args) throws Exception {
Workspace workspace = new Workspace("Styling Relationships", "This is a model of my software system.");
Model model = workspace.getModel();
Person user = model.addPerson("User", "A user of my software system.");
SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "My software system.");
Container webApplication = softwareSystem.addContainer("Web Application", "My web application.", "Java and Spring MVC");
Container database = softwareSystem.addContainer("Database", "My database.", "Relational database schema");
user.uses(webApplication, "Uses", "HTTPS");
webApplication.uses(database, "Reads from and writes to", "JDBC");
ViewSet views = workspace.getViews();
ContainerView containerView = views.createContainerView(softwareSystem, "containers", "An example of a container diagram.");
containerView.addAllElements();
Styles styles = workspace.getViews().getConfiguration().getStyles();
// example 1
// styles.addRelationshipStyle(Tags.RELATIONSHIP).color("#ff0000");
// example 2
// model.getRelationships().stream().filter(r -> "HTTPS".equals(r.getTechnology())).forEach(r -> r.addTags("HTTPS"));
// model.getRelationships().stream().filter(r -> "JDBC".equals(r.getTechnology())).forEach(r -> r.addTags("JDBC"));
// styles.addRelationshipStyle("HTTPS").color("#ff0000");
// styles.addRelationshipStyle("JDBC").color("#0000ff");
StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
}
示例13
/**
* Adds the default set of elements to this view.
*/
@Override
public void addDefaultElements() {
for (Container container : getSoftwareSystem().getContainers()) {
add(container);
addNearestNeighbours(container, Person.class);
addNearestNeighbours(container, SoftwareSystem.class);
}
}
示例14
/**
* Adds all people, software systems and containers that are directly connected to the specified element.
*
* @param element an Element
*/
@Override
public void addNearestNeighbours(@Nonnull Element element) {
super.addNearestNeighbours(element, Person.class);
super.addNearestNeighbours(element, SoftwareSystem.class);
super.addNearestNeighbours(element, Container.class);
}
示例15
/**
* Adds all software systems and people that are directly connected to the specified element.
*
* @param element an Element
*/
@Override
public void addNearestNeighbours(@Nonnull Element element) {
if (element == null) {
throw new IllegalArgumentException("An element must be specified.");
}
if (element instanceof Person || element instanceof SoftwareSystem) {
super.addNearestNeighbours(element, Person.class);
super.addNearestNeighbours(element, SoftwareSystem.class);
} else {
throw new IllegalArgumentException("A person or software system must be specified.");
}
}
示例16
private static void addStyles(ViewSet viewSet) {
Styles styles = viewSet.getConfiguration().getStyles();
styles.addElementStyle(Tags.ELEMENT).color("#000000");
styles.addElementStyle(Tags.PERSON).background("#ffbf00").shape(Shape.Person);
styles.addElementStyle(Tags.CONTAINER).background("#facc2E");
styles.addRelationshipStyle(Tags.RELATIONSHIP).routing(Routing.Orthogonal);
styles.addRelationshipStyle(Tags.ASYNCHRONOUS).dashed(true);
styles.addRelationshipStyle(Tags.SYNCHRONOUS).dashed(false);
}
示例17
public Person getAdmin() {
return admin;
}
示例18
public Person getCustomer() {
return customer;
}
示例19
public static void main(String[] args) throws Exception {
Workspace workspace = new Workspace("Documentation - Viewpoints and Perspectives", "An empty software architecture document using the Viewpoints and Perspectives template.");
Model model = workspace.getModel();
ViewSet views = workspace.getViews();
Person user = model.addPerson("User", "A user of my software system.");
SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "My software system.");
user.uses(softwareSystem, "Uses");
SystemContextView contextView = views.createSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram.");
contextView.addAllSoftwareSystems();
contextView.addAllPeople();
Styles styles = views.getConfiguration().getStyles();
styles.addElementStyle(Tags.PERSON).shape(Shape.Person);
ViewpointsAndPerspectivesDocumentationTemplate template = new ViewpointsAndPerspectivesDocumentationTemplate(workspace);
// this is the Markdown version
File documentationRoot = new File("./structurizr-examples/src/com/structurizr/example/documentation/viewpointsandperspectives/markdown");
template.addIntroductionSection(softwareSystem, new File(documentationRoot, "01-introduction.md"));
template.addGlossarySection(softwareSystem, new File(documentationRoot, "02-glossary.md"));
template.addSystemStakeholdersAndRequirementsSection(softwareSystem, new File(documentationRoot, "03-system-stakeholders-and-requirements.md"));
template.addArchitecturalForcesSection(softwareSystem, new File(documentationRoot, "04-architectural-forces.md"));
template.addArchitecturalViewsSection(softwareSystem, new File(documentationRoot, "05-architectural-views"));
template.addSystemQualitiesSection(softwareSystem, new File(documentationRoot, "06-system-qualities.md"));
template.addAppendicesSection(softwareSystem, new File(documentationRoot, "07-appendices.md"));
// this is the AsciiDoc version
// File documentationRoot = new File("./structurizr-examples/src/com/structurizr/example/documentation/viewpointsandperspectives/asciidoc");
// template.addIntroductionSection(softwareSystem, new File(documentationRoot, "01-introduction.adoc"));
// template.addGlossarySection(softwareSystem, new File(documentationRoot, "02-glossary.adoc"));
// template.addSystemStakeholdersAndRequirementsSection(softwareSystem, new File(documentationRoot, "03-system-stakeholders-and-requirements.adoc"));
// template.addArchitecturalForcesSection(softwareSystem, new File(documentationRoot, "04-architectural-forces.adoc"));
// template.addArchitecturalViewsSection(softwareSystem, new File(documentationRoot, "05-architectural-views"));
// template.addSystemQualitiesSection(softwareSystem, new File(documentationRoot, "06-system-qualities.adoc"));
// template.addAppendicesSection(softwareSystem, new File(documentationRoot, "07-appendices.adoc"));
StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
}
示例20
public static void main(String[] args) throws Exception {
Workspace workspace = new Workspace("Documentation - arc42", "An empty software architecture document using the arc42 template.");
Model model = workspace.getModel();
ViewSet views = workspace.getViews();
Person user = model.addPerson("User", "A user of my software system.");
SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "My software system.");
user.uses(softwareSystem, "Uses");
SystemContextView contextView = views.createSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram.");
contextView.addAllSoftwareSystems();
contextView.addAllPeople();
Styles styles = views.getConfiguration().getStyles();
styles.addElementStyle(Tags.PERSON).shape(Shape.Person);
Arc42DocumentationTemplate template = new Arc42DocumentationTemplate(workspace);
// this is the Markdown version
File documentationRoot = new File("./structurizr-examples/src/com/structurizr/example/documentation/arc42/markdown");
template.addIntroductionAndGoalsSection(softwareSystem, new File(documentationRoot, "01-introduction-and-goals.md"));
template.addConstraintsSection(softwareSystem, new File(documentationRoot, "02-architecture-constraints.md"));
template.addContextAndScopeSection(softwareSystem, new File(documentationRoot, "03-system-scope-and-context.md"));
template.addSolutionStrategySection(softwareSystem, new File(documentationRoot, "04-solution-strategy.md"));
template.addBuildingBlockViewSection(softwareSystem, new File(documentationRoot, "05-building-block-view.md"));
template.addRuntimeViewSection(softwareSystem, new File(documentationRoot, "06-runtime-view.md"));
template.addDeploymentViewSection(softwareSystem, new File(documentationRoot, "07-deployment-view.md"));
template.addCrosscuttingConceptsSection(softwareSystem, new File(documentationRoot, "08-crosscutting-concepts.md"));
template.addArchitecturalDecisionsSection(softwareSystem, new File(documentationRoot, "09-architecture-decisions.md"));
template.addRisksAndTechnicalDebtSection(softwareSystem, new File(documentationRoot, "10-quality-requirements.md"));
template.addQualityRequirementsSection(softwareSystem, new File(documentationRoot, "11-risks-and-technical-debt.md"));
template.addGlossarySection(softwareSystem, new File(documentationRoot, "12-glossary.md"));
// this is the AsciiDoc version
// File documentationRoot = new File("./structurizr-examples/src/com/structurizr/example/documentation/arc42/asciidoc");
// template.addIntroductionAndGoalsSection(softwareSystem, new File(documentationRoot, "01-introduction-and-goals.adoc"));
// template.addConstraintsSection(softwareSystem, new File(documentationRoot, "02-architecture-constraints.adoc"));
// template.addContextAndScopeSection(softwareSystem, new File(documentationRoot, "03-system-scope-and-context.adoc"));
// template.addSolutionStrategySection(softwareSystem, new File(documentationRoot, "04-solution-strategy.adoc"));
// template.addBuildingBlockViewSection(softwareSystem, new File(documentationRoot, "05-building-block-view.adoc"));
// template.addRuntimeViewSection(softwareSystem, new File(documentationRoot, "06-runtime-view.adoc"));
// template.addDeploymentViewSection(softwareSystem, new File(documentationRoot, "07-deployment-view.adoc"));
// template.addCrosscuttingConceptsSection(softwareSystem, new File(documentationRoot, "08-crosscutting-concepts.adoc"));
// template.addArchitecturalDecisionsSection(softwareSystem, new File(documentationRoot, "09-architecture-decisions.adoc"));
// template.addRisksAndTechnicalDebtSection(softwareSystem, new File(documentationRoot, "10-quality-requirements.adoc"));
// template.addQualityRequirementsSection(softwareSystem, new File(documentationRoot, "11-risks-and-technical-debt.adoc"));
// template.addGlossarySection(softwareSystem, new File(documentationRoot, "12-glossary.adoc"));
StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
}
示例21
public static void main(String[] args) throws Exception {
Workspace workspace = new Workspace("Documentation - Structurizr", "An empty software architecture document using the Structurizr template.");
Model model = workspace.getModel();
ViewSet views = workspace.getViews();
Person user = model.addPerson("User", "A user of my software system.");
SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "My software system.");
user.uses(softwareSystem, "Uses");
SystemContextView contextView = views.createSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram.");
contextView.addAllSoftwareSystems();
contextView.addAllPeople();
Styles styles = views.getConfiguration().getStyles();
styles.addElementStyle(Tags.PERSON).shape(Shape.Person);
StructurizrDocumentationTemplate template = new StructurizrDocumentationTemplate(workspace);
// this is the Markdown version
File documentationRoot = new File("./structurizr-examples/src/com/structurizr/example/documentation/structurizr/markdown");
template.addContextSection(softwareSystem, new File(documentationRoot, "01-context.md"));
template.addFunctionalOverviewSection(softwareSystem, new File(documentationRoot, "02-functional-overview.md"));
template.addQualityAttributesSection(softwareSystem, new File(documentationRoot, "03-quality-attributes.md"));
template.addConstraintsSection(softwareSystem, new File(documentationRoot, "04-constraints.md"));
template.addPrinciplesSection(softwareSystem, new File(documentationRoot, "05-principles.md"));
template.addSoftwareArchitectureSection(softwareSystem, new File(documentationRoot, "06-software-architecture.md"));
template.addDataSection(softwareSystem, new File(documentationRoot, "07-data.md"));
template.addInfrastructureArchitectureSection(softwareSystem, new File(documentationRoot, "08-infrastructure-architecture.md"));
template.addDeploymentSection(softwareSystem, new File(documentationRoot, "09-deployment.md"));
template.addDevelopmentEnvironmentSection(softwareSystem, new File(documentationRoot, "10-development-environment.md"));
template.addOperationAndSupportSection(softwareSystem, new File(documentationRoot, "11-operation-and-support.md"));
template.addDecisionLogSection(softwareSystem, new File(documentationRoot, "12-decision-log.md"));
// this is the AsciiDoc version
// File documentationRoot = new File("./structurizr-examples/src/com/structurizr/example/documentation/structurizr/asciidoc");
// template.addContextSection(softwareSystem, new File(documentationRoot, "01-context.adoc"));
// template.addFunctionalOverviewSection(softwareSystem, new File(documentationRoot, "02-functional-overview.adoc"));
// template.addQualityAttributesSection(softwareSystem, new File(documentationRoot, "03-quality-attributes.adoc"));
// template.addConstraintsSection(softwareSystem, new File(documentationRoot, "04-constraints.adoc"));
// template.addPrinciplesSection(softwareSystem, new File(documentationRoot, "05-principles.adoc"));
// template.addSoftwareArchitectureSection(softwareSystem, new File(documentationRoot, "06-software-architecture.adoc"));
// template.addDataSection(softwareSystem, new File(documentationRoot, "07-data.adoc"));
// template.addInfrastructureArchitectureSection(softwareSystem, new File(documentationRoot, "08-infrastructure-architecture.adoc"));
// template.addDeploymentSection(softwareSystem, new File(documentationRoot, "09-deployment.adoc"));
// template.addDevelopmentEnvironmentSection(softwareSystem, new File(documentationRoot, "10-development-environment.adoc"));
// template.addOperationAndSupportSection(softwareSystem, new File(documentationRoot, "11-operation-and-support.adoc"));
// template.addDecisionLogSection(softwareSystem, new File(documentationRoot, "12-decision-log.adoc"));
StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
}
示例22
/**
* Adds the default set of elements to this view.
*/
@Override
public void addDefaultElements() {
addNearestNeighbours(getSoftwareSystem(), Person.class);
addNearestNeighbours(getSoftwareSystem(), SoftwareSystem.class);
}
示例23
/**
* Adds the given person to this view, including relationships to/from that person.
*
* @param person the Person to add
*/
public void add(@Nonnull Person person) {
add(person, true);
}
示例24
/**
* Adds the given person to this view.
*
* @param person the Person to add
* @param addRelationships whether to add relationships to/from the person
*/
public void add(@Nonnull Person person, boolean addRelationships) {
addElement(person, addRelationships);
}
示例25
/**
* Removes the given person from this view.
*
* @param person the Person to add
*/
public void remove(@Nonnull Person person) {
removeElement(person);
}