Giter VIP home page Giter VIP logo

sysml-v2-api-services's Issues

Dockerfile, if anyone finds it useful...

Hi,
I do not know if this has any value for you, but I created a dockerfile for it.
If there is interest, then I also have some files for installing a postgres and creating a docker network between the postgres and the sysml-v2-api-services.

FROM sbtscala/scala-sbt:graalvm-ce-22.3.3-b1-java11_1.9.8_3.3.1
WORKDIR /app
COPY ./ /app

RUN sbt clean && sbt compile
EXPOSE  9000
CMD ["sbt","run"]

add junixsocket to deps to enable socket file based postgresql connection

See c85217b

This commit adds the junixsocket library to the dependencies. This
allows the usage of a UNIX domain socket connection to a postgresql
server. This promises both better performance, and it allows to use
a Linux user identity for authentication against the DB (versus
username/password auth for TCP/IP based communication to the DB).

The change is non-intrusive, i.e. per default TCP/IP is still used and
works as intended.

For more information, checkout:

In particular, setting the following two properties in the
persistence.xml suffices to connect to a postgresql via a socket file:

javax.persistence.jdbc.url='jdbc:postgresql://localhost/db-name?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory$SystemProperty'
org.newsclub.net.unix.socket.default=/run/postgresql/.s.PGSQL.5432
diff --git a/build.sbt b/build.sbt
index 80054dd..12ec88b 100644
--- a/build.sbt
+++ b/build.sbt
@@ -18,6 +18,7 @@ libraryDependencies += "com.fasterxml.jackson.core" % "jackson-databind" % "2.9.
 libraryDependencies += "com.fasterxml.jackson.datatype" % "jackson-datatype-hibernate5" % "2.9.8"
 libraryDependencies += "io.swagger" % "swagger-play2_2.12" % "1.6.0"
 libraryDependencies += "org.reflections" % "reflections" % "0.9.10"
+libraryDependencies += "com.kohlschutter.junixsocket" % "junixsocket-core" % "2.8.3"
 
 javacOptions ++= Seq("-s", "app")

potential issues found in openapi.json - body should be required on POST and PUT methods, document states that these are not required

Dear All,

I am studying the openapi.json file at https://raw.githubusercontent.com/Systems-Modeling/SysML-v2-API-Services/master/public/docs/openapi.json.

The postProject operation as specified between lines 80 and 100:

      "post": {
        "tags": [
          "Project"
        ],
        "summary": "Create project",
        "operationId": "postProject",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProjectRequest"
              },
              "examples": {
                "ProjectRequest": {
                  "$ref": "#/components/examples/ProjectRequest"
                }
              }
            }
          },
          "required": false
        }

states that a POST body is not required (see "required": false. Since one has to specify at least the name and an optional description that seems to be a bit odd. I think it should be "required": true.

The same can be found on the PUT method

API Services default port 9000 conflicts with MinIO

Hello,

I noticed that the current default port in the SysML-v2-API-Services implementation is 9000, which is the also the default port used by MinIO, a very popular open-source S3-compliant object storage. Might be worth considering a different default port for the final implementation?

question: POST for elements

Hello, is there an option to use a POST request to add elements to a specific commit? Thanks for your attention

Project dependencies are not updated

It's unfortunate that the dependencies of this project have not been updated - sbt 1.2.8 vs 1.8.2 etc.
Users could of course do this themselves, but it's not as simple as just changing the sbt version number and things will continue to work. For example, sbt 1.7.2 is the latest version that can be loaded without errors (after fixes to the build.sbt syntax), but it won't compile due to internal errors in twirl.
Using sbt 1.2.8 is problematic due to its dependency on a vulnerable version of log4j.

Seed Data

I have the system up and running on my local machine, but the database is empty so there are no projects to work with. Is there a way to seed the database from a .sysml file I already have?

Open Api scheme model not exist.

Open Api scheme model not exist, i need to prepare the TFG and prepare a diagram drawing from python client on it.

Thanks and Regards

allow overriding of persistence properties with system properties

See 809037c

Prior to this change, the only way to change the persistence settings
was to edit the persistence.xml. In case of a pre-build .jar, the
persistence.xml has to be contained in the .jar with the persistence
module [1], and can not be overridden. However, the current repo
hard-codes the DB connection details in the persistence.xml, which
makes it impossible to override the DB connection details for a fully
built .jar without changing that .jar file.

This change enable the overriding of the properties used for the JPA
EntityManagerFactory with system properties, so that DB connection
details can be altered without changing the .jar file.

diff --git a/app/jpa/manager/impl/HibernateManager.java b/app/jpa/manager/impl/HibernateManager.java
index 793d29c..bf8df83 100644
--- a/app/jpa/manager/impl/HibernateManager.java
+++ b/app/jpa/manager/impl/HibernateManager.java
@@ -38,7 +38,8 @@ public class HibernateManager implements JPAManager {
     private final EntityManagerFactory entityManagerFactory;
 
     public HibernateManager() {
-        entityManagerFactory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
+        entityManagerFactory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME,
+            System.getProperties());
     }
 
     @Override

Non-empty project cannot be deleted due to foreign key constraints in the database

SysML v2 API and Services version: 2022-05 (on Jun 17, 2022)

Steps to reproduce:

  • Using the api client, create a non-empty project (e.g. an empty commit).
  • Send a request to delete this project.

The following simple project reproduces the problem: api-client-bug-report.zip (the project uses the SysML v2 API Java Client). Essential part:

val projectApi = ProjectApi(defaultClient)
val commitApi = CommitApi(defaultClient)
//...
val project = projectApi.postProject(Project().apply {
    name = "demo project"
})
commitApi.postCommitByProject(project.atId, Commit(), null) // An empty commit is added
projectApi.deleteProjectById(project.atId) // Exception: Internal Server Error (update or delete on table "project" violates foreign key constraint)

Expected output: the project is deleted from the database with all of its contents (commits, branches, elements, etc.).

Actual output:
on the demo project side: ApiException: Internal Server Error
in the pilot implementation server:

play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[RollbackException: Error while committing the transaction]]
        at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:351)
        at play.api.http.HttpErrorHandlerExceptions.throwableToUsefulException(HttpErrorHandler.scala)
        at play.http.JsonHttpErrorHandler.throwableToUsefulException(JsonHttpErrorHandler.java:93)
        at play.http.JsonHttpErrorHandler.onServerError(JsonHttpErrorHandler.java:67)
        at play.core.j.JavaHttpErrorHandlerAdapter.$anonfun$onServerError$1(JavaHttpErrorHandlerAdapter.scala:24)
        at play.core.j.JavaHelpers.$anonfun$invokeWithContext$1(JavaHelpers.scala:290)
        at play.core.j.JavaHelpers.withContext(JavaHelpers.scala:302)
        at play.core.j.JavaHelpers.withContext$(JavaHelpers.scala:298)
        at play.core.j.JavaHelpers$.withContext(JavaHelpers.scala:311)
        at play.core.j.JavaHelpers.invokeWithContext(JavaHelpers.scala:289)
Caused by: javax.persistence.RollbackException: Error while committing the transaction
        at org.hibernate.internal.ExceptionConverterImpl.convertCommitException(ExceptionConverterImpl.java:81)
        at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:107)
        at dao.impl.jpa.JpaDao.lambda$deleteById$2(JpaDao.java:91)
        at jpa.manager.impl.HibernateManager.transact(HibernateManager.java:58)
        at dao.impl.jpa.JpaDao.lambda$deleteById$3(JpaDao.java:86)
        at java.base/java.util.Optional.map(Optional.java:265)
        at dao.impl.jpa.JpaDao.deleteById(JpaDao.java:86)
        at services.BaseService.deleteById(BaseService.java:61)
        at controllers.ProjectController.deleteProjectById(ProjectController.java:79)
        at router.Routes$$anonfun$routes$1.$anonfun$applyOrElse$17(Routes.scala:819)
Caused by: javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement
        at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:154)
        at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:181)
        at org.hibernate.internal.ExceptionConverterImpl.convertCommitException(ExceptionConverterImpl.java:65)
        at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:107)
        at dao.impl.jpa.JpaDao.lambda$deleteById$2(JpaDao.java:91)
        at jpa.manager.impl.HibernateManager.transact(HibernateManager.java:58)
        at dao.impl.jpa.JpaDao.lambda$deleteById$3(JpaDao.java:86)
        at java.base/java.util.Optional.map(Optional.java:265)
        at dao.impl.jpa.JpaDao.deleteById(JpaDao.java:86)
        at services.BaseService.deleteById(BaseService.java:61)
Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement
        at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:112)
        at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
        at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)
        at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:99)
        at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:178)
        at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:45)
        at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:3481)
        at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:3738)
        at org.hibernate.action.internal.EntityDeleteAction.execute(EntityDeleteAction.java:99)
        at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:604)
Caused by: org.postgresql.util.PSQLException: ERROR: update or delete on table "project" violates foreign key constraint "fkga25en2ho7o502qrcucb6vgtc" on table "commit"
  Detail: Key (id)=(9810543c-d38c-46e5-b3db-b55b787aaf4a) is still referenced from table "commit".
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2440)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2183)
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:308)
        at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)
        at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)
        at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:143)
        at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:120)
        at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:175)
        at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:45)
        at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:3481)

Project `PUT` method does not work.

SysML v2 API and Services version: 2022-06 (on Jul 18, 2022)

Steps to reproduce:

  • Using the api client, create a project.
  • Modify the name/description of the project with the project PUT method.
  • Get the project details. The returned value of the properties name and description are null.

The following simple Kotlin snippet reproduces the problem: api-client-bug-report.zip (the project uses the SysML v2 API Java Client. Essential part:

val projectApi = ProjectApi(defaultClient)
//...
val project = projectApi.postProject(Project().apply { name = "demo project" })
val MODIFIED_NAME = "modified name"
projectApi.putProjectById(project.atId, project.apply { name = MODIFIED_NAME })
val modifiedProject = projectApi.getProjectById(project.atId)
assert(modifiedProject.name == MODIFIED_NAME) // false: AssertionError (if -ea flag is provided for JVM), modifiedProject.name = null

Expected output: the project name/description is the updated name/description

Actual output: these properties are null

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.