From 79c1c2940f025fb9fe5dc70487446b2b4149a839 Mon Sep 17 00:00:00 2001 From: Jamil RAICHOUNI Date: Thu, 15 Aug 2024 22:34:48 +0200 Subject: [PATCH] feat: Implement endpoints --- CONTRIBUTING.md | 19 -- rest-api/.openapi-generator-ignore | 2 + rest-api/bin/jaxrs-jersey.json.license | 2 + rest-api/bin/jaxrs-jersey.zsh | 4 +- rest-api/openapi/custom.yaml | 42 ++- rest-api/plugin.xml | 3 +- rest-api/pom.xml | 2 +- rest-api/src/Main.java | 35 -- rest-api/src/com/db/capella/Application.java | 18 + rest-api/src/com/db/capella/Main.java | 45 +++ .../src/com/db/capella/api/ApiException.java | 40 +++ .../com/db/capella/api/ApiOriginFilter.java | 25 ++ .../db/capella/api/ApiResponseMessage.java | 69 ++++ .../src/com/db/capella/api/Bootstrap.java | 53 +++ .../db/capella/api/JacksonJsonProvider.java | 34 ++ .../com/db/capella/api/NotFoundException.java | 13 + .../src/com/db/capella/api/ProjectsApi.java | 191 +++++++++++ .../db/capella/api/ProjectsApiService.java | 35 ++ .../com/db/capella/api/RFC3339DateFormat.java | 41 +++ .../capella/api/SelectedModelElementsApi.java | 76 +++++ .../api/SelectedModelElementsApiService.java | 24 ++ .../src/com/db/capella/api/StringUtil.java | 45 +++ .../src/com/db/capella/api/WorkspaceApi.java | 76 +++++ .../db/capella/api/WorkspaceApiService.java | 24 ++ .../factories/ProjectsApiServiceFactory.java | 16 + ...electedModelElementsApiServiceFactory.java | 16 + .../factories/WorkspaceApiServiceFactory.java | 16 + .../api/impl/ProjectsApiServiceImpl.java | 314 ++++++++++++++++++ .../SelectedModelElementsApiServiceImpl.java | 27 ++ .../api/impl/WorkspaceApiServiceImpl.java | 27 ++ .../capella/integration/ReflectionUtils.java | 96 ++++++ .../integration/WorkspaceProjectInt.java | 100 ++++++ .../src/com/db/capella/model/Diagram.java | 179 ++++++++++ .../com/db/capella/model/DiagramEditor.java | 152 +++++++++ .../src/com/db/capella/model/EObject.java | 98 ++++++ .../src/com/db/capella/model/Element.java | 98 ++++++ .../db/capella/model/ExtensibleElement.java | 98 ++++++ .../capella/model/ImportProjectRequest.java | 98 ++++++ .../com/db/capella/model/ModelElement.java | 152 +++++++++ .../src/com/db/capella/model/Resource.java | 152 +++++++++ .../capella/model/SelectedModelElement.java | 233 +++++++++++++ .../src/com/db/capella/model/Workspace.java | 98 ++++++ .../db/capella/model/WorkspaceProject.java | 206 ++++++++++++ 43 files changed, 3035 insertions(+), 59 deletions(-) delete mode 100644 CONTRIBUTING.md create mode 100644 rest-api/bin/jaxrs-jersey.json.license 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/DiagramEditor.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/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 1573de0..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,19 +0,0 @@ - - -# Contributing - -Capella addons are developed on separated branches. To contribute, please -follow these steps: - -1. Fork the repository -1. Create a new branch from the `main` branch and name it according to the - Capella addon (name as defined in the next step) you plan to contribute. -1. Change into the root directory for your local checkout of the present - repository. -1. Create the new addon project using the [project template] which has - according instructions. - -[project template]: https://github.com/DSD-DBS/cookiecutter-dbs-eclipse-addon diff --git a/rest-api/.openapi-generator-ignore b/rest-api/.openapi-generator-ignore index fc678f5..0cee45d 100644 --- a/rest-api/.openapi-generator-ignore +++ b/rest-api/.openapi-generator-ignore @@ -1,3 +1,5 @@ +# Copyright DB InfraGO AG and contributors +# SPDX-License-Identifier: CC0-1.0 README.md pom.xml src/com/db/capella/Main.java diff --git a/rest-api/bin/jaxrs-jersey.json.license b/rest-api/bin/jaxrs-jersey.json.license new file mode 100644 index 0000000..02c8c23 --- /dev/null +++ b/rest-api/bin/jaxrs-jersey.json.license @@ -0,0 +1,2 @@ +Copyright DB InfraGO AG and contributors +SPDX-License-Identifier: Apache-2.0 diff --git a/rest-api/bin/jaxrs-jersey.zsh b/rest-api/bin/jaxrs-jersey.zsh index cc675c6..e99b55b 100755 --- a/rest-api/bin/jaxrs-jersey.zsh +++ b/rest-api/bin/jaxrs-jersey.zsh @@ -1,7 +1,9 @@ #!/usr/bin/env zsh +# Copyright DB InfraGO AG and contributors +# SPDX-License-Identifier: CC0-1.0 SCRIPT_PATH=$(realpath -s $0) SCRIPT_DIR=$(dirname $SCRIPT_PATH) -openapi-generator-cli generate \ +openapi-generator generate \ -i openapi/custom.yaml \ -c $SCRIPT_DIR/jaxrs-jersey.json \ -g jaxrs-jersey \ diff --git a/rest-api/openapi/custom.yaml b/rest-api/openapi/custom.yaml index edb34e1..6762f9a 100644 --- a/rest-api/openapi/custom.yaml +++ b/rest-api/openapi/custom.yaml @@ -1,3 +1,6 @@ +# Copyright DB InfraGO AG and contributors +# SPDX-License-Identifier: Apache-2.0 + openapi: 3.0.3 info: title: Capella API @@ -5,7 +8,7 @@ info: version: 0.0.1 servers: - url: http://localhost:5007/api/v1 - description: Embeded Capella REST API server + description: Embedded Capella REST API server tags: - name: Diagrams description: > @@ -181,6 +184,30 @@ paths: description: Project saved successfully '404': description: Project not found + /projects/{project_name}/diagram-editors: + get: + tags: + - Diagrams + summary: Get a list of all open diagram editors for a project by name + operationId: getDiagramEditorsByProjectName + parameters: + - name: project_name + in: path + required: true + description: Unique name of the project + schema: + type: string + responses: + '200': + description: A list of open diagram editors + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/DiagramEditor' + '404': + description: Project not found /projects/{project_name}/diagrams: get: tags: @@ -236,6 +263,19 @@ components: documentation: type: string description: Documentation of the diagram + DiagramEditor: + type: object + description: A diagram editor in Capella + properties: + id: + type: string + description: Unique identifier of the diagram + name: + type: string + description: Name of the diagram + uri: + type: string + description: URI of the diagram EObject: type: object description: An abstract model object diff --git a/rest-api/plugin.xml b/rest-api/plugin.xml index cc023d7..c15b3b7 100644 --- a/rest-api/plugin.xml +++ b/rest-api/plugin.xml @@ -3,8 +3,7 @@ + class="com.db.capella.Main"> - diff --git a/rest-api/pom.xml b/rest-api/pom.xml index b932f57..644e87d 100644 --- a/rest-api/pom.xml +++ b/rest-api/pom.xml @@ -7,7 +7,7 @@ 0.0.1 2.7.5 - 11 + 17 ${java.version} ${java.version} 2.2.15 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..d461b43 --- /dev/null +++ b/rest-api/src/com/db/capella/Application.java @@ -0,0 +1,18 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +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..0f197b1 --- /dev/null +++ b/rest-api/src/com/db/capella/Main.java @@ -0,0 +1,45 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +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://0.0.0.0: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..df1e364 --- /dev/null +++ b/rest-api/src/com/db/capella/api/ApiException.java @@ -0,0 +1,40 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +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.9.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..725b1d9 --- /dev/null +++ b/rest-api/src/com/db/capella/api/ApiOriginFilter.java @@ -0,0 +1,25 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +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.9.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 {} +} 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..e4891b3 --- /dev/null +++ b/rest-api/src/com/db/capella/api/ApiResponseMessage.java @@ -0,0 +1,69 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +package com.db.capella.api; + + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.9.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..1183d3d --- /dev/null +++ b/rest-api/src/com/db/capella/api/Bootstrap.java @@ -0,0 +1,53 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +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..e14648f --- /dev/null +++ b/rest-api/src/com/db/capella/api/JacksonJsonProvider.java @@ -0,0 +1,34 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +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..6343f2f --- /dev/null +++ b/rest-api/src/com/db/capella/api/NotFoundException.java @@ -0,0 +1,13 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +package com.db.capella.api; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.9.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..5a48505 --- /dev/null +++ b/rest-api/src/com/db/capella/api/ProjectsApi.java @@ -0,0 +1,191 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +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.DiagramEditor; +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.9.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}/diagram-editors") + @Produces({ "application/json" }) + @Operation(summary = "Get a list of all open diagram editors for a project by name", description = "", responses = { + @ApiResponse(responseCode = "200", description = "A list of open diagram editors", content = + @Content(schema = @Schema(implementation = DiagramEditor.class))), + @ApiResponse(responseCode = "404", description = "Project not found", content = + @Content(schema = @Schema(implementation = Void.class))), + }, tags={ "Diagrams", }) + public Response getDiagramEditorsByProjectName(@Schema(description= "Unique name of the project", required = true) @PathParam("project_name") @NotNull String projectName,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.getDiagramEditorsByProjectName(projectName, 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..0d0d816 --- /dev/null +++ b/rest-api/src/com/db/capella/api/ProjectsApiService.java @@ -0,0 +1,35 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +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.DiagramEditor; +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.9.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 getDiagramEditorsByProjectName(String projectName,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..ff9ef83 --- /dev/null +++ b/rest-api/src/com/db/capella/api/RFC3339DateFormat.java @@ -0,0 +1,41 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +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; + } +} 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..2e8a8b3 --- /dev/null +++ b/rest-api/src/com/db/capella/api/SelectedModelElementsApi.java @@ -0,0 +1,76 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +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.9.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..08ac4e0 --- /dev/null +++ b/rest-api/src/com/db/capella/api/SelectedModelElementsApiService.java @@ -0,0 +1,24 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +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.9.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..8aa4e5c --- /dev/null +++ b/rest-api/src/com/db/capella/api/StringUtil.java @@ -0,0 +1,45 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +package com.db.capella.api; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.9.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..79047b3 --- /dev/null +++ b/rest-api/src/com/db/capella/api/WorkspaceApi.java @@ -0,0 +1,76 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +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.9.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..4214a49 --- /dev/null +++ b/rest-api/src/com/db/capella/api/WorkspaceApiService.java @@ -0,0 +1,24 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +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.9.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..9e7d56c --- /dev/null +++ b/rest-api/src/com/db/capella/api/factories/ProjectsApiServiceFactory.java @@ -0,0 +1,16 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +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.9.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..4219cd5 --- /dev/null +++ b/rest-api/src/com/db/capella/api/factories/SelectedModelElementsApiServiceFactory.java @@ -0,0 +1,16 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +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.9.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..48b33d5 --- /dev/null +++ b/rest-api/src/com/db/capella/api/factories/WorkspaceApiServiceFactory.java @@ -0,0 +1,16 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +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.9.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..10557af --- /dev/null +++ b/rest-api/src/com/db/capella/api/impl/ProjectsApiServiceImpl.java @@ -0,0 +1,314 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +package com.db.capella.api.impl; + +import java.io.File; +import java.util.Collection; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; +import org.eclipse.emf.common.util.URI; +import org.eclipse.sirius.business.api.dialect.DialectManager; +import org.eclipse.sirius.business.api.session.Session; +import org.eclipse.sirius.business.api.session.SessionManager; +import org.eclipse.sirius.diagram.ui.part.SiriusDiagramEditor; +import org.eclipse.sirius.ui.business.api.session.SessionEditorInput; +import org.eclipse.sirius.viewpoint.DRepresentationDescriptor; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IEditorReference; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; + +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.Diagram; +import com.db.capella.model.DiagramEditor; +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 static URI getEMFURIForAirdFile(IPath directoryPath) { + File directory = directoryPath.toFile(); + if (directory.isDirectory()) { + File[] files = directory.listFiles((dir, name) -> name.endsWith(".aird")); + if (files != null && files.length > 0) { + // Assuming there's only one .aird file in the directory + File airdFile = files[0]; + return URI.createFileURI(airdFile.getAbsolutePath()); + } + } + return null; + } + + private Session getSession(IProject project) throws ApiException { + URI airdFileName = getEMFURIForAirdFile(project.getLocation()); + if (airdFileName == null) { + throw new ApiException(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), + "An .aird file is required to get the SystemEngineering"); + } + final Session session = SessionManager.INSTANCE.getSession(airdFileName, new NullProgressMonitor()); + if (session == null) { + throw new ApiException(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), + "Cannot get session for project"); + } + return session; + } + + 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 { + IProject workspaceProject; + try { + workspaceProject = getWorkspaceProjectByName(projectName); + } catch (ApiException e) { + return Response.status(Response.Status.NOT_FOUND) + .entity(new ApiResponseMessage(ApiResponseMessage.ERROR, e.getMessage())).build(); + } + try { + workspaceProject.close(null); + } catch (Exception e) { + return Response.status(Response.Status.INTERNAL_SERVER_ERROR) + .entity(new ApiResponseMessage(ApiResponseMessage.ERROR, e.getMessage())).build(); + } + return Response.ok() + .entity(new ApiResponseMessage(ApiResponseMessage.OK, "Project '" + projectName + "' is closed.")) + .build(); + } + + @Override + public Response deleteProjectByName(String projectName, + Boolean deleteContents, + SecurityContext securityContext) + throws NotFoundException { + IProject workspaceProject = null; + try { + workspaceProject = getWorkspaceProjectByName(projectName); + } catch (ApiException e) { + return Response.status(Response.Status.NOT_FOUND) + .entity(new ApiResponseMessage(ApiResponseMessage.ERROR, e.getMessage())).build(); + } + try { + workspaceProject.delete(deleteContents, true, null); + } catch (Exception e) { + return Response.status(Response.Status.INTERNAL_SERVER_ERROR) + .entity(new ApiResponseMessage(ApiResponseMessage.ERROR, e.getMessage())).build(); + } + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "Project deleted")).build(); + } + + @Override + public Response getDiagramEditorsByProjectName(String projectName, SecurityContext securityContext) + throws NotFoundException { + java.util.List diagramEditorList = new java.util.ArrayList(); + IWorkbench workbench = PlatformUI.getWorkbench(); + IWorkbenchWindow[] windows = workbench.getWorkbenchWindows(); + for (IWorkbenchWindow window : windows) { + IWorkbenchPage[] pages = window.getPages(); + for (IWorkbenchPage page : pages) { + IEditorReference[] editorReferences = page.getEditorReferences(); + for (IEditorReference editorReference : editorReferences) { + // IEditorPart editorPart = editorReference.getEditor(false); + // if (editorPart instanceof SiriusDiagramEditor) { + try { + IEditorInput input = editorReference.getEditorInput(); + if (input instanceof SessionEditorInput) { + SessionEditorInput sessionEditorInput = (SessionEditorInput) input; + URI uri = sessionEditorInput.getURI(); + IFile file = ResourcesPlugin.getWorkspace().getRoot() + .getFile(new Path(uri.toPlatformString(true))); + IProject project = file.getProject(); + if (project.getName().equals(projectName)) { + DiagramEditor diagramEditor = new DiagramEditor(); + diagramEditor.setName(sessionEditorInput.getName()); + diagramEditor.setUri(sessionEditorInput.getURI().toString()); + String repDesUri = sessionEditorInput.getRepDescUri().toString(); + diagramEditor.setId(repDesUri.split("#")[1]); + diagramEditorList.add(diagramEditor); + if (editorReference.getEditor(false) == null) { + System.out.println(sessionEditorInput.getName() + " is null"); + } + } + } + } catch (PartInitException e) { + } + } + } + } + + return Response.ok().entity(diagramEditorList).build(); + } + + @Override + public Response getDiagramsByProjectName(String projectName, SecurityContext securityContext) + throws NotFoundException { + IProject workspaceProject = null; + try { + workspaceProject = getWorkspaceProjectByName(projectName); + } catch (ApiException e) { + return Response.status(Response.Status.NOT_FOUND) + .entity(new ApiResponseMessage(ApiResponseMessage.ERROR, e.getMessage())).build(); + } + Session session = null; + try { + session = getSession(workspaceProject); + } catch (ApiException e) { + return Response.status(Response.Status.NOT_FOUND) + .entity(new ApiResponseMessage(ApiResponseMessage.ERROR, e.getMessage())).build(); + } + Collection representationDescriptors = DialectManager.INSTANCE + .getAllRepresentationDescriptors(session); + java.util.List diagramList = new java.util.ArrayList(); + if (true) { + for (DRepresentationDescriptor representationDescriptor : representationDescriptors) { + Diagram diagram = new Diagram(); + diagram.setId(representationDescriptor.getUid()); + diagram.setName(representationDescriptor.getName()); + // DRepresentation representation = + // representationDescriptor.getRepresentation(); + // DDiagram dDiagram = (DDiagram) representation; + // for (DRepresentationElement representationElement : + // representation.getRepresentationElements()) { + // if (representationElement.getTarget() instanceof ModelElement) { + // ModelElement modelElement = (ModelElement) representationElement.getTarget(); + // System.out.println(modelElement.getLabel()); + // System.out.println(modelElement.getFullLabel()); + // } + // } + // diagram.setId(representation.getUid()); + // diagram.setDescription(representationDescriptor.getDescription()); + // diagram.setName(representation.getName()); + diagramList.add(diagram); + } + } + return Response.ok().entity(diagramList).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 body, SecurityContext securityContext) + throws NotFoundException { + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + String projectFolderPath = body.getLocation(); + File projectFolder = new File(projectFolderPath); + if (!projectFolder.exists()) { + return Response.status(Response.Status.NOT_FOUND) + .entity(new ApiResponseMessage(ApiResponseMessage.ERROR, "Project folder not found")).build(); + } + File dotProjectFile = new File(projectFolder, ".project"); + if (!dotProjectFile.exists()) { + return Response.status(Response.Status.BAD_REQUEST) + .entity(new ApiResponseMessage(ApiResponseMessage.ERROR, + "Project folder does not contain .project file")) + .build(); + } + IPath projectLocation = new Path(dotProjectFile.getAbsolutePath()); + try { + IProjectDescription projectDescription = workspace + .loadProjectDescription(projectLocation); + IProject project = workspace.getRoot().getProject(projectDescription.getName()); + if (project.exists()) { + return Response.status(Response.Status.CONFLICT) + .entity(new ApiResponseMessage(ApiResponseMessage.ERROR, "Project already exists")).build(); + } + project.create(projectDescription, null); + project.open(null); + WorkspaceProjectInt projectInt = new WorkspaceProjectInt( + (org.eclipse.core.internal.resources.Project) project); + // todo: URL in response header is `http://localhost:5007/projects/(...)` which + // is wrong + return Response.created(new java.net.URI("/projects/" + projectInt.getName())) + .build(); + } catch (Exception e) { + e.printStackTrace(); + } + return Response.status(Response.Status.INTERNAL_SERVER_ERROR) + .entity(new ApiResponseMessage(ApiResponseMessage.ERROR, "Failed to import project")).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 { + IProject workspaceProject; + try { + workspaceProject = getWorkspaceProjectByName(projectName); + } catch (ApiException e) { + return Response.status(Response.Status.NOT_FOUND) + .entity(new ApiResponseMessage(ApiResponseMessage.ERROR, e.getMessage())).build(); + } + try { + workspaceProject.open(null); + } catch (Exception e) { + return Response.status(Response.Status.INTERNAL_SERVER_ERROR) + .entity(new ApiResponseMessage(ApiResponseMessage.ERROR, e.getMessage())).build(); + } + return Response.ok() + .entity(new ApiResponseMessage(ApiResponseMessage.OK, "Project '" + projectName + "' is opened.")) + .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..5e0a5e5 --- /dev/null +++ b/rest-api/src/com/db/capella/api/impl/SelectedModelElementsApiServiceImpl.java @@ -0,0 +1,27 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +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.9.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..1628964 --- /dev/null +++ b/rest-api/src/com/db/capella/api/impl/WorkspaceApiServiceImpl.java @@ -0,0 +1,27 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +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.9.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..a671665 --- /dev/null +++ b/rest-api/src/com/db/capella/integration/ReflectionUtils.java @@ -0,0 +1,96 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +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..c499adb --- /dev/null +++ b/rest-api/src/com/db/capella/integration/WorkspaceProjectInt.java @@ -0,0 +1,100 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +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..fb053e3 --- /dev/null +++ b/rest-api/src/com/db/capella/model/Diagram.java @@ -0,0 +1,179 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +/* + * 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.9.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/DiagramEditor.java b/rest-api/src/com/db/capella/model/DiagramEditor.java new file mode 100644 index 0000000..2279858 --- /dev/null +++ b/rest-api/src/com/db/capella/model/DiagramEditor.java @@ -0,0 +1,152 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +/* + * 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 editor in Capella + */ +@Schema(description = "A diagram editor in Capella") +@JsonPropertyOrder({ + DiagramEditor.JSON_PROPERTY_ID, + DiagramEditor.JSON_PROPERTY_NAME, + DiagramEditor.JSON_PROPERTY_URI +}) +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.9.0") +public class DiagramEditor { + 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_URI = "uri"; + @JsonProperty(JSON_PROPERTY_URI) + private String uri; + + public DiagramEditor 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 DiagramEditor 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 DiagramEditor uri(String uri) { + this.uri = uri; + return this; + } + + /** + * URI of the diagram + * @return uri + **/ + @JsonProperty(value = "uri") + @Schema(description = "URI of the diagram") + + public String getUri() { + return uri; + } + + public void setUri(String uri) { + this.uri = uri; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DiagramEditor diagramEditor = (DiagramEditor) o; + return Objects.equals(this.id, diagramEditor.id) && + Objects.equals(this.name, diagramEditor.name) && + Objects.equals(this.uri, diagramEditor.uri); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, uri); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DiagramEditor {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" uri: ").append(toIndentedString(uri)).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..cd9836e --- /dev/null +++ b/rest-api/src/com/db/capella/model/EObject.java @@ -0,0 +1,98 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +/* + * 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.9.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..19d1241 --- /dev/null +++ b/rest-api/src/com/db/capella/model/Element.java @@ -0,0 +1,98 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +/* + * 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.9.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..0cfd702 --- /dev/null +++ b/rest-api/src/com/db/capella/model/ExtensibleElement.java @@ -0,0 +1,98 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +/* + * 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.9.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..ae0ee7c --- /dev/null +++ b/rest-api/src/com/db/capella/model/ImportProjectRequest.java @@ -0,0 +1,98 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +/* + * 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.9.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..6185bda --- /dev/null +++ b/rest-api/src/com/db/capella/model/ModelElement.java @@ -0,0 +1,152 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +/* + * 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.9.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..ac14e51 --- /dev/null +++ b/rest-api/src/com/db/capella/model/Resource.java @@ -0,0 +1,152 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +/* + * 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.9.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..9627a3a --- /dev/null +++ b/rest-api/src/com/db/capella/model/SelectedModelElement.java @@ -0,0 +1,233 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +/* + * 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.9.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..cb59c5d --- /dev/null +++ b/rest-api/src/com/db/capella/model/Workspace.java @@ -0,0 +1,98 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +/* + * 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.9.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..5043191 --- /dev/null +++ b/rest-api/src/com/db/capella/model/WorkspaceProject.java @@ -0,0 +1,206 @@ +// Copyright DB InfraGO AG and contributors +// SPDX-License-Identifier: Apache-2.0 + +/* + * 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.9.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 "); + } +}