Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Sirus Web Creating elements programmatically
Sirus Web Creating elements programmatically [message #1843510] Tue, 03 August 2021 09:34 Go to next message
Andre Seecamp is currently offline Andre SeecampFriend
Messages: 13
Registered: July 2021
Junior Member
Hello,

I want to create elements in the Sirius Web environment via code while the Sirius Web Server is running.

I already found that you can save an xml file and change the configuration files to show a custom model but this files are only updated after the server is restarted.

Is there a way to push a new model to the sirius web environment where a refresh of the browser is enough to show the changes?
Re: Sirus Web Creating elements programmatically [message #1843516 is a reply to message #1843510] Tue, 03 August 2021 14:53 Go to previous messageGo to next message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 458
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi,

You should look at the uploadDocument GraphQL mutation in our API to see how we perform the file upload (which would not even require a browser refresh to see the change)

Kind regards,

Stephane B├ęgaudeau, Sirius Web Architect
Re: Sirus Web Creating elements programmatically [message #1843526 is a reply to message #1843516] Wed, 04 August 2021 11:12 Go to previous messageGo to next message
Andre Seecamp is currently offline Andre SeecampFriend
Messages: 13
Registered: July 2021
Junior Member
Thank you. I will take a look at it.
Re: Sirus Web Creating elements programmatically [message #1843579 is a reply to message #1843526] Mon, 09 August 2021 11:51 Go to previous messageGo to next message
Andre Seecamp is currently offline Andre SeecampFriend
Messages: 13
Registered: July 2021
Junior Member
Hello,

I struggle with the query for the document upload (I have not used GraphQL before). I try to upload a file through the GraphiQL interface, but I get an error which I cannot resolve. Later I want to perform this query through java code.

The query looks like this right now
mutation uploadDocument($input: UploadDocumentInput!){ uploadDocument(input: $input) {
  __typename
  ... on ErrorPayload {message}}} 

Query Variables
 { "input": {
    "id": "8016b11c-f8f6-11eb-9a03-0242ac130003",
    "file": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><eed:AHPCC xmi:version=\"2.0\" xmlns:xmi=\"http://www.omg.org/XMI\" xmlns:eed=\"http://www.example.org/eed\"><application name=\"app1\"/></eed:AHPCC>",
    "editingContextId": "f633f3db-65f3-4299-a989-938a47209045"
    }
 }


But I get the following error:
{
  "errors": [
    {
      "message": "Exception while fetching data (/uploadDocument) : null",
      "locations": [
        {
          "line": 14,
          "column": 56
        }
      ],
      "path": [
        "uploadDocument"
      ],
      "extensions": {
        "classification": "DataFetchingException"
      }
    }
  ],
  "data": null
}


What is not correct in my query?

Also, I have not found a way to extract the current representation with the api as XMI. Is there no function for that? Is there another way I can do that?

[Updated on: Mon, 09 August 2021 12:32]

Report message to a moderator

Re: Sirus Web Creating elements programmatically [message #1843659 is a reply to message #1843579] Thu, 12 August 2021 13:38 Go to previous messageGo to next message
Andre Seecamp is currently offline Andre SeecampFriend
Messages: 13
Registered: July 2021
Junior Member
I took a further look into the api and found out that I probably have to use a multipart request. Now I encounter an error which says that I am using the wrong media type.
My request looks like this:
curl localhost:8080/api/graphql \
    -X POST \
    -F operations='{ "query": "mutation uploadDocument($input: UploadDocumentInput!){ uploadDocument(input: $input) { __typename ... on ErrorPayload {message}}}", "variables": { "input": {"id": "8016b11c-f8f6-11eb-9a03-0242ac130003","editingContextId": "531c38f2-d87c-4a41-b740-7693d11a5c40","file": null } } }'\
    -F map='{ "0":["variables.file"] }' \
    -F 0=@Model.json


and the error message is the following:
{
    "timestamp": 1628773563083,
    "status": 415,
    "error": "Unsupported Media Type",
    "path": "/api/graphql"
}


If anybody knows what causes the error I would be grateful for your help.

[Updated on: Thu, 12 August 2021 13:39]

Report message to a moderator

Re: Sirus Web Creating elements programmatically [message #1843816 is a reply to message #1843659] Thu, 19 August 2021 13:04 Go to previous message
Andre Seecamp is currently offline Andre SeecampFriend
Messages: 13
Registered: July 2021
Junior Member
Does no one has an answer? I could need some help with this please.
Previous Topic:[Sirius Web] Rectalinear edges
Next Topic:Set reference to existing class instance with tool
Goto Forum:
  


Current Time: Wed Sep 28 16:21:18 GMT 2022

Powered by FUDForum. Page generated in 0.03966 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top