From 5a526b296d2b6ccd87374308b661c4d93511c753 Mon Sep 17 00:00:00 2001 From: Jamil RAICHOUNI Date: Thu, 15 Aug 2024 22:34:48 +0200 Subject: [PATCH] feat: Implement endpoints for modification/ save --- rest-api/plugin.xml | 2 +- rest-api/src/Main.java | 35 --- rest-api/src/com/db/capella/Application.java | 15 ++ rest-api/src/com/db/capella/Main.java | 42 ++++ .../src/com/db/capella/api/ApiException.java | 37 +++ .../com/db/capella/api/ApiOriginFilter.java | 22 ++ .../db/capella/api/ApiResponseMessage.java | 66 +++++ .../src/com/db/capella/api/Bootstrap.java | 50 ++++ .../db/capella/api/JacksonJsonProvider.java | 31 +++ .../com/db/capella/api/NotFoundException.java | 10 + .../src/com/db/capella/api/ProjectsApi.java | 173 +++++++++++++ .../db/capella/api/ProjectsApiService.java | 30 +++ .../com/db/capella/api/RFC3339DateFormat.java | 38 +++ .../capella/api/SelectedModelElementsApi.java | 73 ++++++ .../api/SelectedModelElementsApiService.java | 21 ++ .../src/com/db/capella/api/StringUtil.java | 42 ++++ .../src/com/db/capella/api/WorkspaceApi.java | 73 ++++++ .../db/capella/api/WorkspaceApiService.java | 21 ++ .../factories/ProjectsApiServiceFactory.java | 13 + ...electedModelElementsApiServiceFactory.java | 13 + .../factories/WorkspaceApiServiceFactory.java | 13 + .../api/impl/ProjectsApiServiceImpl.java | 129 ++++++++++ .../SelectedModelElementsApiServiceImpl.java | 24 ++ .../api/impl/WorkspaceApiServiceImpl.java | 24 ++ .../capella/integration/ReflectionUtils.java | 93 +++++++ .../integration/WorkspaceProjectInt.java | 97 ++++++++ .../src/com/db/capella/model/Diagram.java | 177 ++++++++++++++ .../src/com/db/capella/model/EObject.java | 96 ++++++++ .../src/com/db/capella/model/Element.java | 96 ++++++++ .../db/capella/model/ExtensibleElement.java | 96 ++++++++ .../capella/model/ImportProjectRequest.java | 96 ++++++++ .../com/db/capella/model/ModelElement.java | 150 ++++++++++++ .../src/com/db/capella/model/Resource.java | 150 ++++++++++++ .../capella/model/SelectedModelElement.java | 231 ++++++++++++++++++ .../src/com/db/capella/model/Workspace.java | 96 ++++++++ .../db/capella/model/WorkspaceProject.java | 204 ++++++++++++++++ 36 files changed, 2543 insertions(+), 36 deletions(-) delete mode 100644 rest-api/src/Main.java create mode 100644 rest-api/src/com/db/capella/Application.java create mode 100644 rest-api/src/com/db/capella/Main.java create mode 100644 rest-api/src/com/db/capella/api/ApiException.java create mode 100644 rest-api/src/com/db/capella/api/ApiOriginFilter.java create mode 100644 rest-api/src/com/db/capella/api/ApiResponseMessage.java create mode 100644 rest-api/src/com/db/capella/api/Bootstrap.java create mode 100644 rest-api/src/com/db/capella/api/JacksonJsonProvider.java create mode 100644 rest-api/src/com/db/capella/api/NotFoundException.java create mode 100644 rest-api/src/com/db/capella/api/ProjectsApi.java create mode 100644 rest-api/src/com/db/capella/api/ProjectsApiService.java create mode 100644 rest-api/src/com/db/capella/api/RFC3339DateFormat.java create mode 100644 rest-api/src/com/db/capella/api/SelectedModelElementsApi.java create mode 100644 rest-api/src/com/db/capella/api/SelectedModelElementsApiService.java create mode 100644 rest-api/src/com/db/capella/api/StringUtil.java create mode 100644 rest-api/src/com/db/capella/api/WorkspaceApi.java create mode 100644 rest-api/src/com/db/capella/api/WorkspaceApiService.java create mode 100644 rest-api/src/com/db/capella/api/factories/ProjectsApiServiceFactory.java create mode 100644 rest-api/src/com/db/capella/api/factories/SelectedModelElementsApiServiceFactory.java create mode 100644 rest-api/src/com/db/capella/api/factories/WorkspaceApiServiceFactory.java create mode 100644 rest-api/src/com/db/capella/api/impl/ProjectsApiServiceImpl.java create mode 100644 rest-api/src/com/db/capella/api/impl/SelectedModelElementsApiServiceImpl.java create mode 100644 rest-api/src/com/db/capella/api/impl/WorkspaceApiServiceImpl.java create mode 100644 rest-api/src/com/db/capella/integration/ReflectionUtils.java create mode 100644 rest-api/src/com/db/capella/integration/WorkspaceProjectInt.java create mode 100644 rest-api/src/com/db/capella/model/Diagram.java create mode 100644 rest-api/src/com/db/capella/model/EObject.java create mode 100644 rest-api/src/com/db/capella/model/Element.java create mode 100644 rest-api/src/com/db/capella/model/ExtensibleElement.java create mode 100644 rest-api/src/com/db/capella/model/ImportProjectRequest.java create mode 100644 rest-api/src/com/db/capella/model/ModelElement.java create mode 100644 rest-api/src/com/db/capella/model/Resource.java create mode 100644 rest-api/src/com/db/capella/model/SelectedModelElement.java create mode 100644 rest-api/src/com/db/capella/model/Workspace.java create mode 100644 rest-api/src/com/db/capella/model/WorkspaceProject.java diff --git a/rest-api/plugin.xml b/rest-api/plugin.xml index cc023d7..a20ca35 100644 --- a/rest-api/plugin.xml +++ b/rest-api/plugin.xml @@ -3,7 +3,7 @@ + class="com.db.capella.Main"> diff --git a/rest-api/src/Main.java b/rest-api/src/Main.java deleted file mode 100644 index c9e0203..0000000 --- a/rest-api/src/Main.java +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright DB InfraGO AG and contributors -// SPDX-License-Identifier: Apache-2.0 - -import org.eclipse.ui.IStartup; - -public class Main implements IStartup { - /** - * Will be called in a separate thread after the workbench initializes. - *

- * Note that most workbench methods must be called in the UI thread since they - * may access SWT. For example, to obtain the current workbench window, use: - *

- * - *
-     * 
-     * IWorkbench workbench = PlatformUI.getWorkbench();
-     * workbench.getDisplay().asyncExec(new Runnable() {
-     *   public void run() {
-     *     IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
-     *     if (window != null) {
-     *       // do something
-     *     }
-     *   }
-     * });
-     * 
-     * 
- * - * @see org.eclipse.swt.widgets.Display#asyncExec - * @see org.eclipse.swt.widgets.Display#syncExec - */ - @Override - public void earlyStartup() { - System.out.println("earlyStartup() called"); - } -} diff --git a/rest-api/src/com/db/capella/Application.java b/rest-api/src/com/db/capella/Application.java new file mode 100644 index 0000000..7e1d49f --- /dev/null +++ b/rest-api/src/com/db/capella/Application.java @@ -0,0 +1,15 @@ +package com.db.capella; + +import org.glassfish.jersey.server.ResourceConfig; + +import com.db.capella.api.JacksonJsonProvider; +import com.db.capella.api.ProjectsApi; +import com.db.capella.api.WorkspaceApi; + +public class Application extends ResourceConfig { + public Application() { + register(ProjectsApi.class); + register(WorkspaceApi.class); + register(JacksonJsonProvider.class); + } +} diff --git a/rest-api/src/com/db/capella/Main.java b/rest-api/src/com/db/capella/Main.java new file mode 100644 index 0000000..fd9d7c9 --- /dev/null +++ b/rest-api/src/com/db/capella/Main.java @@ -0,0 +1,42 @@ +package com.db.capella; + +import java.net.URI; + +import org.eclipse.core.runtime.ILog; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.ui.IStartup; +import org.glassfish.grizzly.http.server.HttpServer; +import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; +import org.glassfish.jersey.server.ResourceConfig; +import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; + +public class Main implements IStartup { + public static final String BASE_URI = "http://localhost:5007/api/v1"; + + public static void log(int severity, String message, Throwable exception) { + Bundle bundle = FrameworkUtil.getBundle(Main.class); + ILog log = Platform.getLog(bundle); + IStatus status = new Status(severity, bundle.getSymbolicName(), + message, exception); + log.log(status); + } + + @Override + public void earlyStartup() { + final ResourceConfig resourceConfig = new Application(); + try { + final HttpServer server = GrizzlyHttpServerFactory.createHttpServer( + URI.create(BASE_URI), + resourceConfig, true); + log(IStatus.INFO, "Capella REST API server listens on " + BASE_URI + " ...", null); + } catch (Exception e) { + String msg = "There was an error while starting Capella REST API server."; + log(IStatus.ERROR, msg, null); + System.err.println(msg); + e.printStackTrace(); + } + } +} diff --git a/rest-api/src/com/db/capella/api/ApiException.java b/rest-api/src/com/db/capella/api/ApiException.java new file mode 100644 index 0000000..98cc2b1 --- /dev/null +++ b/rest-api/src/com/db/capella/api/ApiException.java @@ -0,0 +1,37 @@ +package com.db.capella.api; + +/** + * The exception that can be used to store the HTTP status code returned by an API response. + */ +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.7.0") +public class ApiException extends Exception { + /** The HTTP status code. */ + private int code; + + /** + * Constructor. + * + * @param code The HTTP status code. + * @param msg The error message. + */ + public ApiException(int code, String msg) { + super(msg); + this.code = code; + } + + /** + * Get the HTTP status code. + * + * @return The HTTP status code. + */ + public int getCode() { + return code; + } + + @Override + public String toString() { + return "ApiException{" + + "code=" + code + + '}'; + } +} diff --git a/rest-api/src/com/db/capella/api/ApiOriginFilter.java b/rest-api/src/com/db/capella/api/ApiOriginFilter.java new file mode 100644 index 0000000..75dc1fb --- /dev/null +++ b/rest-api/src/com/db/capella/api/ApiOriginFilter.java @@ -0,0 +1,22 @@ +package com.db.capella.api; + +import java.io.IOException; + +import jakarta.servlet.*; +import jakarta.servlet.http.HttpServletResponse; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.7.0") +public class ApiOriginFilter implements jakarta.servlet.Filter { + public void doFilter(ServletRequest request, ServletResponse response, + FilterChain chain) throws IOException, ServletException { + HttpServletResponse res = (HttpServletResponse) response; + res.addHeader("Access-Control-Allow-Origin", "*"); + res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); + res.addHeader("Access-Control-Allow-Headers", "Content-Type"); + chain.doFilter(request, response); + } + + public void destroy() {} + + public void init(FilterConfig filterConfig) throws ServletException {} +} \ No newline at end of file diff --git a/rest-api/src/com/db/capella/api/ApiResponseMessage.java b/rest-api/src/com/db/capella/api/ApiResponseMessage.java new file mode 100644 index 0000000..3a0118f --- /dev/null +++ b/rest-api/src/com/db/capella/api/ApiResponseMessage.java @@ -0,0 +1,66 @@ +package com.db.capella.api; + + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.7.0") +public class ApiResponseMessage { + public static final int ERROR = 1; + public static final int WARNING = 2; + public static final int INFO = 3; + public static final int OK = 4; + public static final int TOO_BUSY = 5; + + int code; + String type; + String message; + + public ApiResponseMessage(){} + + public ApiResponseMessage(int code, String message){ + this.code = code; + switch(code){ + case ERROR: + setType("error"); + break; + case WARNING: + setType("warning"); + break; + case INFO: + setType("info"); + break; + case OK: + setType("ok"); + break; + case TOO_BUSY: + setType("too busy"); + break; + default: + setType("unknown"); + break; + } + this.message = message; + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/rest-api/src/com/db/capella/api/Bootstrap.java b/rest-api/src/com/db/capella/api/Bootstrap.java new file mode 100644 index 0000000..0623b2a --- /dev/null +++ b/rest-api/src/com/db/capella/api/Bootstrap.java @@ -0,0 +1,50 @@ +package com.db.capella.api; + +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import io.swagger.v3.jaxrs2.integration.JaxrsOpenApiContextBuilder; +import io.swagger.v3.oas.integration.*; +import io.swagger.v3.oas.models.*; +import io.swagger.v3.oas.models.info.*; + +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.ServletConfig; +import jakarta.servlet.ServletException; + +public class Bootstrap extends HttpServlet { + + private static final long serialVersionUID = 20230810; + + @Override + public void init(ServletConfig config) throws ServletException { + + Info info = new Info() + .title("OpenAPI Server") + .description("API to access live data and modify Capella projects") + .termsOfService("") + .contact(new Contact() + .email("")) + .license(new License() + .name("") + .url("http://unlicense.org")); + + OpenAPI oas = new OpenAPI(); + oas.info(info); + + SwaggerConfiguration openApiConfig = new SwaggerConfiguration() + .openAPI(oas) + .prettyPrint(true) + .resourcePackages(Stream.of("io.swagger.sample.resource").collect(Collectors.toSet())); + + try { + new JaxrsOpenApiContextBuilder() + .servletConfig(config) + .openApiConfiguration(openApiConfig) + .buildContext(true); + + } catch (OpenApiConfigurationException e) { + throw new RuntimeException(e.getMessage(), e); + } + } +} diff --git a/rest-api/src/com/db/capella/api/JacksonJsonProvider.java b/rest-api/src/com/db/capella/api/JacksonJsonProvider.java new file mode 100644 index 0000000..d1e22bd --- /dev/null +++ b/rest-api/src/com/db/capella/api/JacksonJsonProvider.java @@ -0,0 +1,31 @@ +package com.db.capella.api; + +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; + +import com.fasterxml.jackson.datatype.jsr310.*; + +import com.fasterxml.jackson.jakarta.rs.json.JacksonXmlBindJsonProvider; + +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.ext.Provider; + +@Provider +@Produces({MediaType.APPLICATION_JSON}) +public class JacksonJsonProvider extends JacksonXmlBindJsonProvider { + + public JacksonJsonProvider() { + + ObjectMapper objectMapper = new ObjectMapper() + .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + .enable(SerializationFeature.INDENT_OUTPUT) + .enable(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS) + .registerModule(new JavaTimeModule()) + .setDateFormat(new RFC3339DateFormat()); + + setMapper(objectMapper); + } +} diff --git a/rest-api/src/com/db/capella/api/NotFoundException.java b/rest-api/src/com/db/capella/api/NotFoundException.java new file mode 100644 index 0000000..96c8e34 --- /dev/null +++ b/rest-api/src/com/db/capella/api/NotFoundException.java @@ -0,0 +1,10 @@ +package com.db.capella.api; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.7.0") +public class NotFoundException extends ApiException { + private int code; + public NotFoundException (int code, String msg) { + super(code, msg); + this.code = code; + } +} diff --git a/rest-api/src/com/db/capella/api/ProjectsApi.java b/rest-api/src/com/db/capella/api/ProjectsApi.java new file mode 100644 index 0000000..2d81b6e --- /dev/null +++ b/rest-api/src/com/db/capella/api/ProjectsApi.java @@ -0,0 +1,173 @@ +package com.db.capella.api; + +import com.db.capella.api.ProjectsApiService; +import com.db.capella.api.factories.ProjectsApiServiceFactory; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; + +import com.db.capella.model.Diagram; +import com.db.capella.model.ImportProjectRequest; +import com.db.capella.model.WorkspaceProject; + +import java.util.Map; +import java.util.List; +import com.db.capella.api.NotFoundException; + +import java.io.InputStream; + +import org.glassfish.jersey.media.multipart.FormDataParam; +import org.glassfish.jersey.media.multipart.FormDataBodyPart; + +import jakarta.servlet.ServletConfig; +import jakarta.ws.rs.core.Context; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.SecurityContext; +import jakarta.ws.rs.*; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; + +@Path("/projects") + + +@Tag(description = "the projects API", name = "") +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.7.0") +public class ProjectsApi { + + private final ProjectsApiService delegate; + + public ProjectsApi(@Context ServletConfig servletContext) { + + ProjectsApiService delegate = null; + if (servletContext != null) { + String implClass = servletContext.getInitParameter("ProjectsApi.implementation"); + if (implClass != null && !"".equals(implClass.trim())) { + try { + delegate = (ProjectsApiService) Class.forName(implClass).getDeclaredConstructor().newInstance(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + + if (delegate == null) { + delegate = ProjectsApiServiceFactory.getProjectsApi(); + } + this.delegate = delegate; + } + + + @jakarta.ws.rs.POST + @Path("/{project_name}/close") + @Operation(summary = "Close a project by name", description = "", responses = { + @ApiResponse(responseCode = "200", description = "Project closed successfully", content = + @Content(schema = @Schema(implementation = Void.class))), + @ApiResponse(responseCode = "404", description = "Project not found", content = + @Content(schema = @Schema(implementation = Void.class))), + }, tags={ "Projects", }) + public Response closeProjectByName(@Schema(description= "Unique name of the project to be closed", required = true) @PathParam("project_name") @NotNull String projectName,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.closeProjectByName(projectName, securityContext); + } + + @jakarta.ws.rs.DELETE + @Path("/{project_name}") + @Operation(summary = "Delete a project by name", description = "", responses = { + @ApiResponse(responseCode = "200", description = "Project deleted successfully", content = + @Content(schema = @Schema(implementation = Void.class))), + @ApiResponse(responseCode = "404", description = "Project not found", content = + @Content(schema = @Schema(implementation = Void.class))), + }, tags={ "Projects", }) + public Response deleteProjectByName(@Schema(description= "Unique name of the project to be deleted", required = true) @PathParam("project_name") @NotNull String projectName,@Schema(description = "Whether to delete the project contents on disk (cannot be undone) or not ", defaultValue = "false") @DefaultValue("false") @QueryParam("deleteContents") Boolean deleteContents,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.deleteProjectByName(projectName, deleteContents, securityContext); + } + + @jakarta.ws.rs.GET + @Path("/{project_name}/diagrams") + @Produces({ "application/json" }) + @Operation(summary = "Get a list of all diagrams for a project by name", description = "", responses = { + @ApiResponse(responseCode = "200", description = "A list of diagrams", content = + @Content(schema = @Schema(implementation = Diagram.class))), + @ApiResponse(responseCode = "404", description = "Project not found", content = + @Content(schema = @Schema(implementation = Void.class))), + }, tags={ "Diagrams", }) + public Response getDiagramsByProjectName(@Schema(description= "Unique name of the project", required = true) @PathParam("project_name") @NotNull String projectName,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.getDiagramsByProjectName(projectName, securityContext); + } + + @jakarta.ws.rs.GET + @Path("/{project_name}") + @Produces({ "application/json" }) + @Operation(summary = "Get a project by name", description = "", responses = { + @ApiResponse(responseCode = "200", description = "Successful operation", content = + @Content(schema = @Schema(implementation = WorkspaceProject.class))), + @ApiResponse(responseCode = "404", description = "Project not found", content = + @Content(schema = @Schema(implementation = Void.class))), + }, tags={ "Projects", }) + public Response getProjectByName(@Schema(description= "Unique name of the project", required = true) @PathParam("project_name") @NotNull String projectName,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.getProjectByName(projectName, securityContext); + } + + @jakarta.ws.rs.POST + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @Operation(summary = "Import a project into the workspace", description = "", responses = { + @ApiResponse(responseCode = "201", description = "Project imported successfully.", content = + @Content(schema = @Schema(implementation = WorkspaceProject.class))), + @ApiResponse(responseCode = "400", description = "Invalid request", content = + @Content(schema = @Schema(implementation = Void.class))), + @ApiResponse(responseCode = "404", description = "Project not found", content = + @Content(schema = @Schema(implementation = Void.class))), + @ApiResponse(responseCode = "409", description = "Project already exists in the workspace", content = + @Content(schema = @Schema(implementation = Void.class))), + }, tags={ "Projects", }) + public Response importProject(@Schema(description = "", required = true) @NotNull @Valid ImportProjectRequest importProjectRequest,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.importProject(importProjectRequest, securityContext); + } + + @jakarta.ws.rs.GET + @Produces({ "application/json" }) + @Operation(summary = "List all projects in the workspace", description = "", responses = { + @ApiResponse(responseCode = "200", description = "A list of projects", content = + @Content(schema = @Schema(implementation = WorkspaceProject.class))), + }, tags={ "Projects", }) + public Response listProjects(@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.listProjects(securityContext); + } + + @jakarta.ws.rs.POST + @Path("/{project_name}/open") + @Operation(summary = "Open a project by name", description = "", responses = { + @ApiResponse(responseCode = "200", description = "Project opened successfully", content = + @Content(schema = @Schema(implementation = Void.class))), + @ApiResponse(responseCode = "404", description = "Project not found", content = + @Content(schema = @Schema(implementation = Void.class))), + }, tags={ "Projects", }) + public Response openProjectByName(@Schema(description= "Unique name of the project to be opened", required = true) @PathParam("project_name") @NotNull String projectName,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.openProjectByName(projectName, securityContext); + } + + @jakarta.ws.rs.POST + @Path("/{project_name}/save") + @Operation(summary = "Save a project by name", description = "", responses = { + @ApiResponse(responseCode = "200", description = "Project saved successfully", content = + @Content(schema = @Schema(implementation = Void.class))), + @ApiResponse(responseCode = "404", description = "Project not found", content = + @Content(schema = @Schema(implementation = Void.class))), + }, tags={ "Projects", }) + public Response saveProjectByName(@Schema(description= "Unique name of the project to be saved", required = true) @PathParam("project_name") @NotNull String projectName,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.saveProjectByName(projectName, securityContext); + } +} diff --git a/rest-api/src/com/db/capella/api/ProjectsApiService.java b/rest-api/src/com/db/capella/api/ProjectsApiService.java new file mode 100644 index 0000000..e6e1bd6 --- /dev/null +++ b/rest-api/src/com/db/capella/api/ProjectsApiService.java @@ -0,0 +1,30 @@ +package com.db.capella.api; + +import com.db.capella.api.*; + +import org.glassfish.jersey.media.multipart.FormDataBodyPart; + +import com.db.capella.model.Diagram; +import com.db.capella.model.ImportProjectRequest; +import com.db.capella.model.WorkspaceProject; + +import java.util.List; +import com.db.capella.api.NotFoundException; + +import java.io.InputStream; + +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.SecurityContext; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.7.0") +public abstract class ProjectsApiService { + public abstract Response closeProjectByName(String projectName,SecurityContext securityContext) throws NotFoundException; + public abstract Response deleteProjectByName(String projectName,Boolean deleteContents,SecurityContext securityContext) throws NotFoundException; + public abstract Response getDiagramsByProjectName(String projectName,SecurityContext securityContext) throws NotFoundException; + public abstract Response getProjectByName(String projectName,SecurityContext securityContext) throws NotFoundException; + public abstract Response importProject(ImportProjectRequest importProjectRequest,SecurityContext securityContext) throws NotFoundException; + public abstract Response listProjects(SecurityContext securityContext) throws NotFoundException; + public abstract Response openProjectByName(String projectName,SecurityContext securityContext) throws NotFoundException; + public abstract Response saveProjectByName(String projectName,SecurityContext securityContext) throws NotFoundException; +} diff --git a/rest-api/src/com/db/capella/api/RFC3339DateFormat.java b/rest-api/src/com/db/capella/api/RFC3339DateFormat.java new file mode 100644 index 0000000..9d08fbd --- /dev/null +++ b/rest-api/src/com/db/capella/api/RFC3339DateFormat.java @@ -0,0 +1,38 @@ +package com.db.capella.api; + +import com.fasterxml.jackson.databind.util.StdDateFormat; + +import java.text.DateFormat; +import java.text.FieldPosition; +import java.text.ParsePosition; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.TimeZone; + +public class RFC3339DateFormat extends DateFormat { + private static final long serialVersionUID = 1L; + private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC"); + + private final StdDateFormat fmt = new StdDateFormat() + .withTimeZone(TIMEZONE_Z) + .withColonInTimeZone(true); + + public RFC3339DateFormat() { + this.calendar = new GregorianCalendar(); + } + + @Override + public Date parse(String source, ParsePosition pos) { + return fmt.parse(source, pos); + } + + @Override + public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { + return fmt.format(date, toAppendTo, fieldPosition); + } + + @Override + public Object clone() { + return this; + } +} \ No newline at end of file diff --git a/rest-api/src/com/db/capella/api/SelectedModelElementsApi.java b/rest-api/src/com/db/capella/api/SelectedModelElementsApi.java new file mode 100644 index 0000000..243c572 --- /dev/null +++ b/rest-api/src/com/db/capella/api/SelectedModelElementsApi.java @@ -0,0 +1,73 @@ +package com.db.capella.api; + +import com.db.capella.api.SelectedModelElementsApiService; +import com.db.capella.api.factories.SelectedModelElementsApiServiceFactory; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; + +import com.db.capella.model.SelectedModelElement; + +import java.util.Map; +import java.util.List; +import com.db.capella.api.NotFoundException; + +import java.io.InputStream; + +import org.glassfish.jersey.media.multipart.FormDataParam; +import org.glassfish.jersey.media.multipart.FormDataBodyPart; + +import jakarta.servlet.ServletConfig; +import jakarta.ws.rs.core.Context; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.SecurityContext; +import jakarta.ws.rs.*; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; + +@Path("/selected-model-elements") + + +@Tag(description = "the selected-model-elements API", name = "") +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.7.0") +public class SelectedModelElementsApi { + + private final SelectedModelElementsApiService delegate; + + public SelectedModelElementsApi(@Context ServletConfig servletContext) { + + SelectedModelElementsApiService delegate = null; + if (servletContext != null) { + String implClass = servletContext.getInitParameter("SelectedModelElementsApi.implementation"); + if (implClass != null && !"".equals(implClass.trim())) { + try { + delegate = (SelectedModelElementsApiService) Class.forName(implClass).getDeclaredConstructor().newInstance(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + + if (delegate == null) { + delegate = SelectedModelElementsApiServiceFactory.getSelectedModelElementsApi(); + } + this.delegate = delegate; + } + + + @jakarta.ws.rs.GET + @Produces({ "application/json" }) + @Operation(summary = "Get the currently selected model elements", description = "", responses = { + @ApiResponse(responseCode = "200", description = "Successful operation", content = + @Content(schema = @Schema(implementation = SelectedModelElement.class))), + }, tags={ }) + public Response getSelectedModelElements(@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.getSelectedModelElements(securityContext); + } +} diff --git a/rest-api/src/com/db/capella/api/SelectedModelElementsApiService.java b/rest-api/src/com/db/capella/api/SelectedModelElementsApiService.java new file mode 100644 index 0000000..4c7d5d6 --- /dev/null +++ b/rest-api/src/com/db/capella/api/SelectedModelElementsApiService.java @@ -0,0 +1,21 @@ +package com.db.capella.api; + +import com.db.capella.api.*; + +import org.glassfish.jersey.media.multipart.FormDataBodyPart; + +import com.db.capella.model.SelectedModelElement; + +import java.util.List; +import com.db.capella.api.NotFoundException; + +import java.io.InputStream; + +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.SecurityContext; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.7.0") +public abstract class SelectedModelElementsApiService { + public abstract Response getSelectedModelElements(SecurityContext securityContext) throws NotFoundException; +} diff --git a/rest-api/src/com/db/capella/api/StringUtil.java b/rest-api/src/com/db/capella/api/StringUtil.java new file mode 100644 index 0000000..e805b1c --- /dev/null +++ b/rest-api/src/com/db/capella/api/StringUtil.java @@ -0,0 +1,42 @@ +package com.db.capella.api; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.7.0") +public class StringUtil { + /** + * Check if the given array contains the given value (with case-insensitive comparison). + * + * @param array The array + * @param value The value to search + * @return true if the array contains the value + */ + public static boolean containsIgnoreCase(String[] array, String value) { + for (String str : array) { + if (value == null && str == null) return true; + if (value != null && value.equalsIgnoreCase(str)) return true; + } + return false; + } + + /** + * Join an array of strings with the given separator. + *

+ * Note: This might be replaced by utility method from commons-lang or guava someday + * if one of those libraries is added as dependency. + *

+ * + * @param array The array of strings + * @param separator The separator + * @return the resulting string + */ + public static String join(String[] array, String separator) { + int len = array.length; + if (len == 0) return ""; + + StringBuilder out = new StringBuilder(); + out.append(array[0]); + for (int i = 1; i < len; i++) { + out.append(separator).append(array[i]); + } + return out.toString(); + } +} diff --git a/rest-api/src/com/db/capella/api/WorkspaceApi.java b/rest-api/src/com/db/capella/api/WorkspaceApi.java new file mode 100644 index 0000000..58b1c40 --- /dev/null +++ b/rest-api/src/com/db/capella/api/WorkspaceApi.java @@ -0,0 +1,73 @@ +package com.db.capella.api; + +import com.db.capella.api.WorkspaceApiService; +import com.db.capella.api.factories.WorkspaceApiServiceFactory; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; + +import com.db.capella.model.Workspace; + +import java.util.Map; +import java.util.List; +import com.db.capella.api.NotFoundException; + +import java.io.InputStream; + +import org.glassfish.jersey.media.multipart.FormDataParam; +import org.glassfish.jersey.media.multipart.FormDataBodyPart; + +import jakarta.servlet.ServletConfig; +import jakarta.ws.rs.core.Context; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.SecurityContext; +import jakarta.ws.rs.*; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; + +@Path("/workspace") + + +@Tag(description = "the workspace API", name = "") +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.7.0") +public class WorkspaceApi { + + private final WorkspaceApiService delegate; + + public WorkspaceApi(@Context ServletConfig servletContext) { + + WorkspaceApiService delegate = null; + if (servletContext != null) { + String implClass = servletContext.getInitParameter("WorkspaceApi.implementation"); + if (implClass != null && !"".equals(implClass.trim())) { + try { + delegate = (WorkspaceApiService) Class.forName(implClass).getDeclaredConstructor().newInstance(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + + if (delegate == null) { + delegate = WorkspaceApiServiceFactory.getWorkspaceApi(); + } + this.delegate = delegate; + } + + + @jakarta.ws.rs.GET + @Produces({ "application/json" }) + @Operation(summary = "Get the current workspace", description = "", responses = { + @ApiResponse(responseCode = "200", description = "Successful operation", content = + @Content(schema = @Schema(implementation = Workspace.class))), + }, tags={ "Workspace", }) + public Response getWorkspace(@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.getWorkspace(securityContext); + } +} diff --git a/rest-api/src/com/db/capella/api/WorkspaceApiService.java b/rest-api/src/com/db/capella/api/WorkspaceApiService.java new file mode 100644 index 0000000..4115463 --- /dev/null +++ b/rest-api/src/com/db/capella/api/WorkspaceApiService.java @@ -0,0 +1,21 @@ +package com.db.capella.api; + +import com.db.capella.api.*; + +import org.glassfish.jersey.media.multipart.FormDataBodyPart; + +import com.db.capella.model.Workspace; + +import java.util.List; +import com.db.capella.api.NotFoundException; + +import java.io.InputStream; + +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.SecurityContext; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.7.0") +public abstract class WorkspaceApiService { + public abstract Response getWorkspace(SecurityContext securityContext) throws NotFoundException; +} diff --git a/rest-api/src/com/db/capella/api/factories/ProjectsApiServiceFactory.java b/rest-api/src/com/db/capella/api/factories/ProjectsApiServiceFactory.java new file mode 100644 index 0000000..b2c15ea --- /dev/null +++ b/rest-api/src/com/db/capella/api/factories/ProjectsApiServiceFactory.java @@ -0,0 +1,13 @@ +package com.db.capella.api.factories; + +import com.db.capella.api.ProjectsApiService; +import com.db.capella.api.impl.ProjectsApiServiceImpl; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.7.0") +public class ProjectsApiServiceFactory { + private static final ProjectsApiService service = new ProjectsApiServiceImpl(); + + public static ProjectsApiService getProjectsApi() { + return service; + } +} diff --git a/rest-api/src/com/db/capella/api/factories/SelectedModelElementsApiServiceFactory.java b/rest-api/src/com/db/capella/api/factories/SelectedModelElementsApiServiceFactory.java new file mode 100644 index 0000000..70099ce --- /dev/null +++ b/rest-api/src/com/db/capella/api/factories/SelectedModelElementsApiServiceFactory.java @@ -0,0 +1,13 @@ +package com.db.capella.api.factories; + +import com.db.capella.api.SelectedModelElementsApiService; +import com.db.capella.api.impl.SelectedModelElementsApiServiceImpl; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.7.0") +public class SelectedModelElementsApiServiceFactory { + private static final SelectedModelElementsApiService service = new SelectedModelElementsApiServiceImpl(); + + public static SelectedModelElementsApiService getSelectedModelElementsApi() { + return service; + } +} diff --git a/rest-api/src/com/db/capella/api/factories/WorkspaceApiServiceFactory.java b/rest-api/src/com/db/capella/api/factories/WorkspaceApiServiceFactory.java new file mode 100644 index 0000000..df72381 --- /dev/null +++ b/rest-api/src/com/db/capella/api/factories/WorkspaceApiServiceFactory.java @@ -0,0 +1,13 @@ +package com.db.capella.api.factories; + +import com.db.capella.api.WorkspaceApiService; +import com.db.capella.api.impl.WorkspaceApiServiceImpl; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.7.0") +public class WorkspaceApiServiceFactory { + private static final WorkspaceApiService service = new WorkspaceApiServiceImpl(); + + public static WorkspaceApiService getWorkspaceApi() { + return service; + } +} diff --git a/rest-api/src/com/db/capella/api/impl/ProjectsApiServiceImpl.java b/rest-api/src/com/db/capella/api/impl/ProjectsApiServiceImpl.java new file mode 100644 index 0000000..bf251a5 --- /dev/null +++ b/rest-api/src/com/db/capella/api/impl/ProjectsApiServiceImpl.java @@ -0,0 +1,129 @@ +package com.db.capella.api.impl; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.part.FileEditorInput; + +import com.db.capella.api.ApiException; +import com.db.capella.api.ApiResponseMessage; +import com.db.capella.api.NotFoundException; +import com.db.capella.api.ProjectsApiService; +import com.db.capella.integration.WorkspaceProjectInt; +import com.db.capella.model.ImportProjectRequest; + +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.SecurityContext; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.7.0") +public class ProjectsApiServiceImpl extends ProjectsApiService { + private IProject getWorkspaceProjectByName(String name) throws ApiException { + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + IProject workspaceProject = workspace.getRoot().getProject(name); + if (!workspaceProject.exists()) { + throw new ApiException(Response.Status.NOT_FOUND.getStatusCode(), "Project named '" + name + "' not found"); + } + return workspaceProject; + } + + @Override + public Response closeProjectByName(String projectName, + SecurityContext securityContext) + throws NotFoundException { + // do some magic! + return Response.ok() + .entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")) + .build(); + } + + @Override + public Response deleteProjectByName(String projectName, + Boolean deleteContents, + SecurityContext securityContext) + throws NotFoundException { + // do some magic! + return Response.ok() + .entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")) + .build(); + } + + @Override + public Response getDiagramsByProjectName(String projectName, + SecurityContext securityContext) + throws NotFoundException { + // do some magic! + return Response.ok() + .entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")) + .build(); + } + + @Override + public Response getProjectByName(String projectName, + SecurityContext securityContext) + throws NotFoundException { + // do some magic! + return Response.ok() + .entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")) + .build(); + } + + @Override + public Response importProject(ImportProjectRequest importProjectRequest, + SecurityContext securityContext) + throws NotFoundException { + // do some magic! + return Response.ok() + .entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")) + .build(); + } + + @Override + public Response listProjects(SecurityContext securityContext) + throws NotFoundException { + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + IProject[] projects = workspace.getRoot().getProjects(); + java.util.List projectIntList = new java.util.ArrayList(); + for (IProject project : projects) { + WorkspaceProjectInt projectInt = new WorkspaceProjectInt( + (org.eclipse.core.internal.resources.Project) project); + projectIntList.add(projectInt); + } + return Response.ok().entity(projectIntList).build(); + } + + @Override + public Response openProjectByName(String projectName, + SecurityContext securityContext) + throws NotFoundException { + // do some magic! + return Response.ok() + .entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")) + .build(); + } + + @Override + public Response saveProjectByName(String projectName, + SecurityContext securityContext) + throws NotFoundException { + IProject workspaceProject; + try { + workspaceProject = getWorkspaceProjectByName(projectName); + } catch (ApiException e) { + return Response.status(Response.Status.NOT_FOUND) + .entity(new ApiResponseMessage(ApiResponseMessage.ERROR, e.getMessage())).build(); + } + WorkspaceProjectInt projectInt = new WorkspaceProjectInt( + (org.eclipse.core.internal.resources.Project) workspaceProject); + projectInt.save(); + return Response.ok() + .entity(new ApiResponseMessage(ApiResponseMessage.OK, "Project '" + projectName + "' is saved.")) + .build(); + } +} diff --git a/rest-api/src/com/db/capella/api/impl/SelectedModelElementsApiServiceImpl.java b/rest-api/src/com/db/capella/api/impl/SelectedModelElementsApiServiceImpl.java new file mode 100644 index 0000000..217dbaf --- /dev/null +++ b/rest-api/src/com/db/capella/api/impl/SelectedModelElementsApiServiceImpl.java @@ -0,0 +1,24 @@ +package com.db.capella.api.impl; + +import com.db.capella.api.*; +import com.db.capella.model.SelectedModelElement; + +import java.util.List; +import com.db.capella.api.NotFoundException; + +import java.io.InputStream; + +import org.glassfish.jersey.media.multipart.FormDataBodyPart; + +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.SecurityContext; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.7.0") +public class SelectedModelElementsApiServiceImpl extends SelectedModelElementsApiService { + @Override + public Response getSelectedModelElements(SecurityContext securityContext) throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } +} diff --git a/rest-api/src/com/db/capella/api/impl/WorkspaceApiServiceImpl.java b/rest-api/src/com/db/capella/api/impl/WorkspaceApiServiceImpl.java new file mode 100644 index 0000000..4111286 --- /dev/null +++ b/rest-api/src/com/db/capella/api/impl/WorkspaceApiServiceImpl.java @@ -0,0 +1,24 @@ +package com.db.capella.api.impl; + +import com.db.capella.api.*; +import com.db.capella.model.Workspace; + +import java.util.List; +import com.db.capella.api.NotFoundException; + +import java.io.InputStream; + +import org.glassfish.jersey.media.multipart.FormDataBodyPart; + +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.SecurityContext; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.7.0") +public class WorkspaceApiServiceImpl extends WorkspaceApiService { + @Override + public Response getWorkspace(SecurityContext securityContext) throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } +} diff --git a/rest-api/src/com/db/capella/integration/ReflectionUtils.java b/rest-api/src/com/db/capella/integration/ReflectionUtils.java new file mode 100644 index 0000000..40f535d --- /dev/null +++ b/rest-api/src/com/db/capella/integration/ReflectionUtils.java @@ -0,0 +1,93 @@ +package com.db.capella.integration; + +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; + +public class ReflectionUtils { + public static void copyProperties(Object source, Object target) { + Class sourceClass = source.getClass(); + Class targetClass = target.getClass(); + + Map getters = getGetters(sourceClass); + Map setters = getSetters(targetClass); + + for (Map.Entry getterEntry : getters.entrySet()) { + String propName = getterEntry.getKey(); + Method getterMethod = getterEntry.getValue(); + if (setters.containsKey(propName)) { + Method setterMethod = setters.get(propName); + try { + Object value = getterMethod.invoke(source); + setterMethod.invoke(target, value); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + + public static Map getGetters(Class clazz) { + Map getters = new HashMap<>(); + populateGetters(getters, clazz); + return getters; + } + + public static Map getSetters(Class clazz) { + Map setters = new HashMap<>(); + populateSetters(setters, clazz); + return setters; + } + + public static void populateGetters(Map getters, Class clazz) { + if (clazz == null || clazz == Object.class) { + return; + } + Method[] methods = clazz.getDeclaredMethods(); + for (Method method : methods) { + if (isGetter(method)) { + String propName = extractPropertyName(method.getName()); + getters.putIfAbsent(propName, method); + } + } + populateGetters(getters, clazz.getSuperclass()); + } + + public static void populateSetters(Map setters, Class clazz) { + if (clazz == null || clazz == Object.class) { + return; + } + Method[] methods = clazz.getDeclaredMethods(); + for (Method method : methods) { + if (isSetter(method)) { + String propName = extractPropertyName(method.getName()); + setters.putIfAbsent(propName, method); + } + } + populateSetters(setters, clazz.getSuperclass()); + } + + public static boolean isGetter(Method method) { + return method.getParameterTypes().length == 0 + && (method.getName().startsWith("get") || method.getName().startsWith("is")); + } + + public static boolean isSetter(Method method) { + return method.getName().startsWith("set") && + method.getParameterTypes().length == 1; + } + + public static String extractPropertyName(String methodName) { + String prefix = ""; + if (methodName.startsWith("get")) { + prefix = "get"; + } else if (methodName.startsWith("is")) { + prefix = "is"; + } else if (methodName.startsWith("set")) { + prefix = "set"; + } + String propName = methodName.substring(prefix.length(), prefix.length() + + 1).toLowerCase() + methodName.substring(prefix.length() + 1); + return propName; + } +} diff --git a/rest-api/src/com/db/capella/integration/WorkspaceProjectInt.java b/rest-api/src/com/db/capella/integration/WorkspaceProjectInt.java new file mode 100644 index 0000000..628a9b7 --- /dev/null +++ b/rest-api/src/com/db/capella/integration/WorkspaceProjectInt.java @@ -0,0 +1,97 @@ +package com.db.capella.integration; + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IPath; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.part.FileEditorInput; + +import com.db.capella.model.WorkspaceProject; +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.ALWAYS) +public class WorkspaceProjectInt extends WorkspaceProject { + org.eclipse.core.resources.IProject obj; + + public WorkspaceProjectInt(org.eclipse.core.resources.IProject obj) { + super(); + this.obj = obj; + ReflectionUtils.copyProperties(obj, this); + this.computeModified(); + } + + public void computeModified() { + this.setModified(false); + IWorkbench workbench = PlatformUI.getWorkbench(); + IWorkbenchWindow[] windows = workbench.getWorkbenchWindows(); + for (IWorkbenchWindow window : windows) { + IWorkbenchPage[] pages = window.getPages(); + for (IWorkbenchPage page : pages) { + IEditorPart[] editors = page.getDirtyEditors(); + for (IEditorPart editor : editors) { + if (editor.getEditorInput() instanceof FileEditorInput) { + FileEditorInput input = (FileEditorInput) editor.getEditorInput(); + IResource resource = input.getFile(); + if (resource.getProject().equals(this.obj)) { + // Found a dirty editor in the project + this.setModified(true); + return; + } + } + } + } + } + } + + public void save() { + org.eclipse.core.resources.IProject obj = this.obj; + Display.getDefault().asyncExec(new Runnable() { + @Override + public void run() { + IWorkbench workbench = PlatformUI.getWorkbench(); + IWorkbenchWindow[] workbenchWindows = workbench.getWorkbenchWindows(); + + for (IWorkbenchWindow window : workbenchWindows) { + IWorkbenchPage[] pages = window.getPages(); + for (IWorkbenchPage page : pages) { + IEditorPart[] editors = page.getDirtyEditors(); + for (IEditorPart editor : editors) { + if (editor.getEditorInput() instanceof FileEditorInput) { + FileEditorInput input = (FileEditorInput) editor.getEditorInput(); + IResource resource = input.getFile(); + org.eclipse.core.resources.IProject editorProject = resource.getProject(); + + // Check if the editor is associated with the given + // project + if (obj.equals(editorProject)) { + // Save the editor + page.saveEditor(editor, false); + } + } + } + } + } + } + }); + } + + public void setFullPath(IPath fullPath) { + if (fullPath == null) { + this.setFullPath(""); + } else { + this.setFullPath(fullPath.toString()); + } + } + + public void setLocation(IPath location) { + if (location == null) { + this.setLocation(""); + } else { + this.setLocation(location.toString()); + } + } +} diff --git a/rest-api/src/com/db/capella/model/Diagram.java b/rest-api/src/com/db/capella/model/Diagram.java new file mode 100644 index 0000000..9d89dac --- /dev/null +++ b/rest-api/src/com/db/capella/model/Diagram.java @@ -0,0 +1,177 @@ +/* + * Capella API + * API to access live data and modify Capella projects + * + * The version of the OpenAPI document: 0.0.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.db.capella.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.v3.oas.annotations.media.Schema; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; + +/** + * A diagram + */ +@Schema(description = "A diagram") +@JsonPropertyOrder({ + Diagram.JSON_PROPERTY_ID, + Diagram.JSON_PROPERTY_NAME, + Diagram.JSON_PROPERTY_DESCRIPTION, + Diagram.JSON_PROPERTY_DOCUMENTATION +}) +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.7.0") +public class Diagram { + public static final String JSON_PROPERTY_ID = "id"; + @JsonProperty(JSON_PROPERTY_ID) + private String id; + + public static final String JSON_PROPERTY_NAME = "name"; + @JsonProperty(JSON_PROPERTY_NAME) + private String name; + + public static final String JSON_PROPERTY_DESCRIPTION = "description"; + @JsonProperty(JSON_PROPERTY_DESCRIPTION) + private String description; + + public static final String JSON_PROPERTY_DOCUMENTATION = "documentation"; + @JsonProperty(JSON_PROPERTY_DOCUMENTATION) + private String documentation; + + public Diagram id(String id) { + this.id = id; + return this; + } + + /** + * Unique identifier of the diagram + * @return id + **/ + @JsonProperty(value = "id") + @Schema(description = "Unique identifier of the diagram") + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Diagram name(String name) { + this.name = name; + return this; + } + + /** + * Name of the diagram + * @return name + **/ + @JsonProperty(value = "name") + @Schema(description = "Name of the diagram") + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Diagram description(String description) { + this.description = description; + return this; + } + + /** + * Description of the diagram + * @return description + **/ + @JsonProperty(value = "description") + @Schema(description = "Description of the diagram") + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Diagram documentation(String documentation) { + this.documentation = documentation; + return this; + } + + /** + * Documentation of the diagram + * @return documentation + **/ + @JsonProperty(value = "documentation") + @Schema(description = "Documentation of the diagram") + + public String getDocumentation() { + return documentation; + } + + public void setDocumentation(String documentation) { + this.documentation = documentation; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Diagram diagram = (Diagram) o; + return Objects.equals(this.id, diagram.id) && + Objects.equals(this.name, diagram.name) && + Objects.equals(this.description, diagram.description) && + Objects.equals(this.documentation, diagram.documentation); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, description, documentation); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Diagram {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" documentation: ").append(toIndentedString(documentation)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/rest-api/src/com/db/capella/model/EObject.java b/rest-api/src/com/db/capella/model/EObject.java new file mode 100644 index 0000000..0f840e3 --- /dev/null +++ b/rest-api/src/com/db/capella/model/EObject.java @@ -0,0 +1,96 @@ +/* + * Capella API + * API to access live data and modify Capella projects + * + * The version of the OpenAPI document: 0.0.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.db.capella.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.v3.oas.annotations.media.Schema; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; + +/** + * An abstract model object + */ +@Schema(description = "An abstract model object") +@JsonPropertyOrder({ + EObject.JSON_PROPERTY_D_U_M_M_Y +}) +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.7.0") +public class EObject { + public static final String JSON_PROPERTY_D_U_M_M_Y = "DUMMY"; + @JsonProperty(JSON_PROPERTY_D_U_M_M_Y) + private String DUMMY; + + public EObject DUMMY(String DUMMY) { + this.DUMMY = DUMMY; + return this; + } + + /** + * Dummy property + * @return DUMMY + **/ + @JsonProperty(value = "DUMMY") + @Schema(description = "Dummy property") + + public String getDUMMY() { + return DUMMY; + } + + public void setDUMMY(String DUMMY) { + this.DUMMY = DUMMY; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EObject eobject = (EObject) o; + return Objects.equals(this.DUMMY, eobject.DUMMY); + } + + @Override + public int hashCode() { + return Objects.hash(DUMMY); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EObject {\n"); + + sb.append(" DUMMY: ").append(toIndentedString(DUMMY)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/rest-api/src/com/db/capella/model/Element.java b/rest-api/src/com/db/capella/model/Element.java new file mode 100644 index 0000000..e13623a --- /dev/null +++ b/rest-api/src/com/db/capella/model/Element.java @@ -0,0 +1,96 @@ +/* + * Capella API + * API to access live data and modify Capella projects + * + * The version of the OpenAPI document: 0.0.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.db.capella.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.v3.oas.annotations.media.Schema; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; + +/** + * An element + */ +@Schema(description = "An element") +@JsonPropertyOrder({ + Element.JSON_PROPERTY_D_U_M_M_Y +}) +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.7.0") +public class Element { + public static final String JSON_PROPERTY_D_U_M_M_Y = "DUMMY"; + @JsonProperty(JSON_PROPERTY_D_U_M_M_Y) + private String DUMMY; + + public Element DUMMY(String DUMMY) { + this.DUMMY = DUMMY; + return this; + } + + /** + * Dummy property + * @return DUMMY + **/ + @JsonProperty(value = "DUMMY") + @Schema(description = "Dummy property") + + public String getDUMMY() { + return DUMMY; + } + + public void setDUMMY(String DUMMY) { + this.DUMMY = DUMMY; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Element element = (Element) o; + return Objects.equals(this.DUMMY, element.DUMMY); + } + + @Override + public int hashCode() { + return Objects.hash(DUMMY); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Element {\n"); + + sb.append(" DUMMY: ").append(toIndentedString(DUMMY)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/rest-api/src/com/db/capella/model/ExtensibleElement.java b/rest-api/src/com/db/capella/model/ExtensibleElement.java new file mode 100644 index 0000000..f33a179 --- /dev/null +++ b/rest-api/src/com/db/capella/model/ExtensibleElement.java @@ -0,0 +1,96 @@ +/* + * Capella API + * API to access live data and modify Capella projects + * + * The version of the OpenAPI document: 0.0.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.db.capella.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.v3.oas.annotations.media.Schema; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; + +/** + * An extensible element + */ +@Schema(description = "An extensible element") +@JsonPropertyOrder({ + ExtensibleElement.JSON_PROPERTY_D_U_M_M_Y +}) +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.7.0") +public class ExtensibleElement { + public static final String JSON_PROPERTY_D_U_M_M_Y = "DUMMY"; + @JsonProperty(JSON_PROPERTY_D_U_M_M_Y) + private String DUMMY; + + public ExtensibleElement DUMMY(String DUMMY) { + this.DUMMY = DUMMY; + return this; + } + + /** + * Dummy property + * @return DUMMY + **/ + @JsonProperty(value = "DUMMY") + @Schema(description = "Dummy property") + + public String getDUMMY() { + return DUMMY; + } + + public void setDUMMY(String DUMMY) { + this.DUMMY = DUMMY; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExtensibleElement extensibleElement = (ExtensibleElement) o; + return Objects.equals(this.DUMMY, extensibleElement.DUMMY); + } + + @Override + public int hashCode() { + return Objects.hash(DUMMY); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExtensibleElement {\n"); + + sb.append(" DUMMY: ").append(toIndentedString(DUMMY)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/rest-api/src/com/db/capella/model/ImportProjectRequest.java b/rest-api/src/com/db/capella/model/ImportProjectRequest.java new file mode 100644 index 0000000..4e2afb5 --- /dev/null +++ b/rest-api/src/com/db/capella/model/ImportProjectRequest.java @@ -0,0 +1,96 @@ +/* + * Capella API + * API to access live data and modify Capella projects + * + * The version of the OpenAPI document: 0.0.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.db.capella.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import io.swagger.v3.oas.annotations.media.Schema; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; + +/** + * ImportProjectRequest + */ +@JsonPropertyOrder({ + ImportProjectRequest.JSON_PROPERTY_LOCATION +}) +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.7.0") +public class ImportProjectRequest { + public static final String JSON_PROPERTY_LOCATION = "location"; + @JsonProperty(JSON_PROPERTY_LOCATION) + private String location; + + public ImportProjectRequest location(String location) { + this.location = location; + return this; + } + + /** + * Absolute path of the project folder in the local file system + * @return location + **/ + @JsonProperty(value = "location") + @Schema(required = true, description = "Absolute path of the project folder in the local file system ") + @NotNull + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ImportProjectRequest importProjectRequest = (ImportProjectRequest) o; + return Objects.equals(this.location, importProjectRequest.location); + } + + @Override + public int hashCode() { + return Objects.hash(location); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ImportProjectRequest {\n"); + + sb.append(" location: ").append(toIndentedString(location)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/rest-api/src/com/db/capella/model/ModelElement.java b/rest-api/src/com/db/capella/model/ModelElement.java new file mode 100644 index 0000000..c584de4 --- /dev/null +++ b/rest-api/src/com/db/capella/model/ModelElement.java @@ -0,0 +1,150 @@ +/* + * Capella API + * API to access live data and modify Capella projects + * + * The version of the OpenAPI document: 0.0.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.db.capella.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.v3.oas.annotations.media.Schema; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; + +/** + * Common base for all capella elements [source: capella study] Used in levels: operational,system,logical,physical,epbs + */ +@Schema(description = "Common base for all capella elements [source: capella study] Used in levels: operational,system,logical,physical,epbs") +@JsonPropertyOrder({ + ModelElement.JSON_PROPERTY_ID, + ModelElement.JSON_PROPERTY_SID, + ModelElement.JSON_PROPERTY_D_U_M_M_Y +}) +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.7.0") +public class ModelElement { + public static final String JSON_PROPERTY_ID = "id"; + @JsonProperty(JSON_PROPERTY_ID) + private String id; + + public static final String JSON_PROPERTY_SID = "sid"; + @JsonProperty(JSON_PROPERTY_SID) + private String sid; + + public static final String JSON_PROPERTY_D_U_M_M_Y = "DUMMY"; + @JsonProperty(JSON_PROPERTY_D_U_M_M_Y) + private String DUMMY; + + public ModelElement id(String id) { + this.id = id; + return this; + } + + /** + * The unique identifier for this element [source: capella study] + * @return id + **/ + @JsonProperty(value = "id") + @Schema(description = "The unique identifier for this element [source: capella study]") + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public ModelElement sid(String sid) { + this.sid = sid; + return this; + } + + /** + * The unique system identifier for this element + * @return sid + **/ + @JsonProperty(value = "sid") + @Schema(description = "The unique system identifier for this element") + + public String getSid() { + return sid; + } + + public void setSid(String sid) { + this.sid = sid; + } + + public ModelElement DUMMY(String DUMMY) { + this.DUMMY = DUMMY; + return this; + } + + /** + * Dummy property + * @return DUMMY + **/ + @JsonProperty(value = "DUMMY") + @Schema(description = "Dummy property") + + public String getDUMMY() { + return DUMMY; + } + + public void setDUMMY(String DUMMY) { + this.DUMMY = DUMMY; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelElement modelElement = (ModelElement) o; + return Objects.equals(this.id, modelElement.id) && + Objects.equals(this.sid, modelElement.sid) && + Objects.equals(this.DUMMY, modelElement.DUMMY); + } + + @Override + public int hashCode() { + return Objects.hash(id, sid, DUMMY); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelElement {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" sid: ").append(toIndentedString(sid)).append("\n"); + sb.append(" DUMMY: ").append(toIndentedString(DUMMY)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/rest-api/src/com/db/capella/model/Resource.java b/rest-api/src/com/db/capella/model/Resource.java new file mode 100644 index 0000000..6ee5e60 --- /dev/null +++ b/rest-api/src/com/db/capella/model/Resource.java @@ -0,0 +1,150 @@ +/* + * Capella API + * API to access live data and modify Capella projects + * + * The version of the OpenAPI document: 0.0.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.db.capella.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.v3.oas.annotations.media.Schema; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; + +/** + * A generic resource + */ +@Schema(description = "A generic resource") +@JsonPropertyOrder({ + Resource.JSON_PROPERTY_FULL_PATH, + Resource.JSON_PROPERTY_LOCATION, + Resource.JSON_PROPERTY_NAME +}) +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.7.0") +public class Resource { + public static final String JSON_PROPERTY_FULL_PATH = "fullPath"; + @JsonProperty(JSON_PROPERTY_FULL_PATH) + private String fullPath; + + public static final String JSON_PROPERTY_LOCATION = "location"; + @JsonProperty(JSON_PROPERTY_LOCATION) + private String location; + + public static final String JSON_PROPERTY_NAME = "name"; + @JsonProperty(JSON_PROPERTY_NAME) + private String name = ""; + + public Resource fullPath(String fullPath) { + this.fullPath = fullPath; + return this; + } + + /** + * Full, absolute path of the resource relative to the workspace. A resource's full path indicates the route from the root of the workspace to the resource. Within a workspace, there is exactly one such path for any given resource. The first segment of these paths name a project; remaining segments, folders and/or files within that project. The returned path never has a trailing separator. + * @return fullPath + **/ + @JsonProperty(value = "fullPath") + @Schema(description = "Full, absolute path of the resource relative to the workspace. A resource's full path indicates the route from the root of the workspace to the resource. Within a workspace, there is exactly one such path for any given resource. The first segment of these paths name a project; remaining segments, folders and/or files within that project. The returned path never has a trailing separator. ") + + public String getFullPath() { + return fullPath; + } + + public void setFullPath(String fullPath) { + this.fullPath = fullPath; + } + + public Resource location(String location) { + this.location = location; + return this; + } + + /** + * Location of the resource in the file system + * @return location + **/ + @JsonProperty(value = "location") + @Schema(description = "Location of the resource in the file system") + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } + + public Resource name(String name) { + this.name = name; + return this; + } + + /** + * Name of the resource. The workspace root's name is the empty string. + * @return name + **/ + @JsonProperty(value = "name") + @Schema(description = "Name of the resource. The workspace root's name is the empty string. ") + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Resource resource = (Resource) o; + return Objects.equals(this.fullPath, resource.fullPath) && + Objects.equals(this.location, resource.location) && + Objects.equals(this.name, resource.name); + } + + @Override + public int hashCode() { + return Objects.hash(fullPath, location, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Resource {\n"); + + sb.append(" fullPath: ").append(toIndentedString(fullPath)).append("\n"); + sb.append(" location: ").append(toIndentedString(location)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/rest-api/src/com/db/capella/model/SelectedModelElement.java b/rest-api/src/com/db/capella/model/SelectedModelElement.java new file mode 100644 index 0000000..90f7149 --- /dev/null +++ b/rest-api/src/com/db/capella/model/SelectedModelElement.java @@ -0,0 +1,231 @@ +/* + * Capella API + * API to access live data and modify Capella projects + * + * The version of the OpenAPI document: 0.0.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.db.capella.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.v3.oas.annotations.media.Schema; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; + +/** + * The selected Capella model element + */ +@Schema(description = "The selected Capella model element") +@JsonPropertyOrder({ + SelectedModelElement.JSON_PROPERTY_NAME, + SelectedModelElement.JSON_PROPERTY_DESCRIPTION, + SelectedModelElement.JSON_PROPERTY_TYPE, + SelectedModelElement.JSON_PROPERTY_ID, + SelectedModelElement.JSON_PROPERTY_SID, + SelectedModelElement.JSON_PROPERTY_D_U_M_M_Y +}) +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.7.0") +public class SelectedModelElement { + public static final String JSON_PROPERTY_NAME = "name"; + @JsonProperty(JSON_PROPERTY_NAME) + private String name; + + public static final String JSON_PROPERTY_DESCRIPTION = "description"; + @JsonProperty(JSON_PROPERTY_DESCRIPTION) + private String description; + + public static final String JSON_PROPERTY_TYPE = "type"; + @JsonProperty(JSON_PROPERTY_TYPE) + private String type; + + public static final String JSON_PROPERTY_ID = "id"; + @JsonProperty(JSON_PROPERTY_ID) + private String id; + + public static final String JSON_PROPERTY_SID = "sid"; + @JsonProperty(JSON_PROPERTY_SID) + private String sid; + + public static final String JSON_PROPERTY_D_U_M_M_Y = "DUMMY"; + @JsonProperty(JSON_PROPERTY_D_U_M_M_Y) + private String DUMMY; + + public SelectedModelElement name(String name) { + this.name = name; + return this; + } + + /** + * The name of the selected element + * @return name + **/ + @JsonProperty(value = "name") + @Schema(description = "The name of the selected element") + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public SelectedModelElement description(String description) { + this.description = description; + return this; + } + + /** + * The description of the selected element + * @return description + **/ + @JsonProperty(value = "description") + @Schema(description = "The description of the selected element") + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public SelectedModelElement type(String type) { + this.type = type; + return this; + } + + /** + * The type of the selected element + * @return type + **/ + @JsonProperty(value = "type") + @Schema(description = "The type of the selected element") + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public SelectedModelElement id(String id) { + this.id = id; + return this; + } + + /** + * The unique identifier for this element [source: capella study] + * @return id + **/ + @JsonProperty(value = "id") + @Schema(description = "The unique identifier for this element [source: capella study]") + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public SelectedModelElement sid(String sid) { + this.sid = sid; + return this; + } + + /** + * The unique system identifier for this element + * @return sid + **/ + @JsonProperty(value = "sid") + @Schema(description = "The unique system identifier for this element") + + public String getSid() { + return sid; + } + + public void setSid(String sid) { + this.sid = sid; + } + + public SelectedModelElement DUMMY(String DUMMY) { + this.DUMMY = DUMMY; + return this; + } + + /** + * Dummy property + * @return DUMMY + **/ + @JsonProperty(value = "DUMMY") + @Schema(description = "Dummy property") + + public String getDUMMY() { + return DUMMY; + } + + public void setDUMMY(String DUMMY) { + this.DUMMY = DUMMY; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SelectedModelElement selectedModelElement = (SelectedModelElement) o; + return Objects.equals(this.name, selectedModelElement.name) && + Objects.equals(this.description, selectedModelElement.description) && + Objects.equals(this.type, selectedModelElement.type) && + Objects.equals(this.id, selectedModelElement.id) && + Objects.equals(this.sid, selectedModelElement.sid) && + Objects.equals(this.DUMMY, selectedModelElement.DUMMY); + } + + @Override + public int hashCode() { + return Objects.hash(name, description, type, id, sid, DUMMY); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SelectedModelElement {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" sid: ").append(toIndentedString(sid)).append("\n"); + sb.append(" DUMMY: ").append(toIndentedString(DUMMY)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/rest-api/src/com/db/capella/model/Workspace.java b/rest-api/src/com/db/capella/model/Workspace.java new file mode 100644 index 0000000..7460bc6 --- /dev/null +++ b/rest-api/src/com/db/capella/model/Workspace.java @@ -0,0 +1,96 @@ +/* + * Capella API + * API to access live data and modify Capella projects + * + * The version of the OpenAPI document: 0.0.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.db.capella.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.v3.oas.annotations.media.Schema; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; + +/** + * The current workspace + */ +@Schema(description = "The current workspace") +@JsonPropertyOrder({ + Workspace.JSON_PROPERTY_LOCATION +}) +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.7.0") +public class Workspace { + public static final String JSON_PROPERTY_LOCATION = "location"; + @JsonProperty(JSON_PROPERTY_LOCATION) + private String location; + + public Workspace location(String location) { + this.location = location; + return this; + } + + /** + * Location of the resource in the file system + * @return location + **/ + @JsonProperty(value = "location") + @Schema(description = "Location of the resource in the file system") + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Workspace workspace = (Workspace) o; + return Objects.equals(this.location, workspace.location); + } + + @Override + public int hashCode() { + return Objects.hash(location); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Workspace {\n"); + + sb.append(" location: ").append(toIndentedString(location)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/rest-api/src/com/db/capella/model/WorkspaceProject.java b/rest-api/src/com/db/capella/model/WorkspaceProject.java new file mode 100644 index 0000000..7e5a527 --- /dev/null +++ b/rest-api/src/com/db/capella/model/WorkspaceProject.java @@ -0,0 +1,204 @@ +/* + * Capella API + * API to access live data and modify Capella projects + * + * The version of the OpenAPI document: 0.0.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.db.capella.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.v3.oas.annotations.media.Schema; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; + +/** + * A workspace project + */ +@Schema(description = "A workspace project") +@JsonPropertyOrder({ + WorkspaceProject.JSON_PROPERTY_OPEN, + WorkspaceProject.JSON_PROPERTY_MODIFIED, + WorkspaceProject.JSON_PROPERTY_FULL_PATH, + WorkspaceProject.JSON_PROPERTY_LOCATION, + WorkspaceProject.JSON_PROPERTY_NAME +}) +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.7.0") +public class WorkspaceProject { + public static final String JSON_PROPERTY_OPEN = "open"; + @JsonProperty(JSON_PROPERTY_OPEN) + private Boolean open; + + public static final String JSON_PROPERTY_MODIFIED = "modified"; + @JsonProperty(JSON_PROPERTY_MODIFIED) + private Boolean modified = false; + + public static final String JSON_PROPERTY_FULL_PATH = "fullPath"; + @JsonProperty(JSON_PROPERTY_FULL_PATH) + private String fullPath; + + public static final String JSON_PROPERTY_LOCATION = "location"; + @JsonProperty(JSON_PROPERTY_LOCATION) + private String location; + + public static final String JSON_PROPERTY_NAME = "name"; + @JsonProperty(JSON_PROPERTY_NAME) + private String name = ""; + + public WorkspaceProject open(Boolean open) { + this.open = open; + return this; + } + + /** + * Whether the project is open or not + * @return open + **/ + @JsonProperty(value = "open") + @Schema(description = "Whether the project is open or not") + + public Boolean getOpen() { + return open; + } + + public void setOpen(Boolean open) { + this.open = open; + } + + public WorkspaceProject modified(Boolean modified) { + this.modified = modified; + return this; + } + + /** + * Whether the project is in a dirty (unsaved changes) state or not + * @return modified + **/ + @JsonProperty(value = "modified") + @Schema(description = "Whether the project is in a dirty (unsaved changes) state or not") + + public Boolean getModified() { + return modified; + } + + public void setModified(Boolean modified) { + this.modified = modified; + } + + public WorkspaceProject fullPath(String fullPath) { + this.fullPath = fullPath; + return this; + } + + /** + * Full, absolute path of the resource relative to the workspace. A resource's full path indicates the route from the root of the workspace to the resource. Within a workspace, there is exactly one such path for any given resource. The first segment of these paths name a project; remaining segments, folders and/or files within that project. The returned path never has a trailing separator. + * @return fullPath + **/ + @JsonProperty(value = "fullPath") + @Schema(description = "Full, absolute path of the resource relative to the workspace. A resource's full path indicates the route from the root of the workspace to the resource. Within a workspace, there is exactly one such path for any given resource. The first segment of these paths name a project; remaining segments, folders and/or files within that project. The returned path never has a trailing separator. ") + + public String getFullPath() { + return fullPath; + } + + public void setFullPath(String fullPath) { + this.fullPath = fullPath; + } + + public WorkspaceProject location(String location) { + this.location = location; + return this; + } + + /** + * Location of the resource in the file system + * @return location + **/ + @JsonProperty(value = "location") + @Schema(description = "Location of the resource in the file system") + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } + + public WorkspaceProject name(String name) { + this.name = name; + return this; + } + + /** + * Name of the resource. The workspace root's name is the empty string. + * @return name + **/ + @JsonProperty(value = "name") + @Schema(description = "Name of the resource. The workspace root's name is the empty string. ") + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WorkspaceProject workspaceProject = (WorkspaceProject) o; + return Objects.equals(this.open, workspaceProject.open) && + Objects.equals(this.modified, workspaceProject.modified) && + Objects.equals(this.fullPath, workspaceProject.fullPath) && + Objects.equals(this.location, workspaceProject.location) && + Objects.equals(this.name, workspaceProject.name); + } + + @Override + public int hashCode() { + return Objects.hash(open, modified, fullPath, location, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WorkspaceProject {\n"); + + sb.append(" open: ").append(toIndentedString(open)).append("\n"); + sb.append(" modified: ").append(toIndentedString(modified)).append("\n"); + sb.append(" fullPath: ").append(toIndentedString(fullPath)).append("\n"); + sb.append(" location: ").append(toIndentedString(location)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} +