Access project
To get or modify models using Astah System Safety API, you need to access the project first.
How to access a project
In order to access a project, you need to use ProjectAccessor.
You can access only one project at a time. So when you want to edit more than one project, make sure you open only one project at a time, and close before you move to another. Here’s a sample for how to use ProjectAccessor.
// Getting ProjectAccessor
= AstahAPI.getAstahAPI().getProjectAccessor();
ProjectAccessor projectAccessor
try {
// Register a project
if (new File(PROJECT_PATH).exists()) {
System.out.println("Opening Project : " + PROJECT_PATH);
.open(PROJECT_PATH);
projectAccessor} else {
System.out.println("Creating Project : " + PROJECT_PATH);
.create(PROJECT_PATH);
projectAccessor.save();
projectAccessor}
// Reference process
// Editing process
// Save the project
if (!projectAccessor.isProjectModified()) {
return;
}
System.out.println("Save the project.");
.save();
projectAccessor
} finally {
// Close a Project
.close();
projectAccessorSystem.out.println("Closed the project.");
}
Get facet models
SysML,GSN and STAMP/STPA, etc. are managed in their facet models. All the models and presentations exist in the facet Model which can be accessed by calling getFacets()of ProjectAccessor.
public List<IFacet> getProjectFacets(ProjectAccessor projectAccessor) throws ProjectNotFoundException {
return projectAccessor.getFacets();
}