systems-modeling / sysml-v2-api-services Goto Github PK
View Code? Open in Web Editor NEWProof-of-concept pilot implementation for the Systems Modeling API and Services.
License: GNU Lesser General Public License v3.0
Proof-of-concept pilot implementation for the Systems Modeling API and Services.
License: GNU Lesser General Public License v3.0
Hello, is there an option to use a POST request to add elements to a specific commit? Thanks for your attention
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")
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
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"]
SysML v2 API and Services version: 2022-06 (on Jul 18, 2022)
Steps to reproduce:
PUT
method.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
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
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?
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?
SysML v2 API and Services version: 2022-05 (on Jun 17, 2022)
Steps to reproduce:
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)
From what I can gather from the "Systems Modeling Application Programming Interface (API) and Services" version 1.0, release 2022-11 the property referencedCommit
and head
(which redefines referencedCommit) of the Branch
class are not nullable.
When executing the following HTTP request
http://sysml2-sst.intercax.com:9000/projects/8e085296-7e28-4d1d-bbbc-d28beffac3d7/branches
it is apparent that the server returns faulty data.
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
When making a cross-origin request to the service, only the content-length
and content-type
headers are exposed. Tested with the service hosted at http://sysml2.intercax.com:9000/ . The Link
header should be exposed to allow pagination. Appears that play.filters.cors.exposedHeaders
is the appropriate option.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.