Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Roundtrip Issue: Can't go from text mode to form node when a workspace node is unknown #2271

Closed
1 of 2 tasks
theodosis1989 opened this issue May 26, 2023 · 0 comments · Fixed by #2276
Closed
1 of 2 tasks
Assignees
Milestone

Comments

@theodosis1989
Copy link

Similar issues

  • I have searched and found no existing similar issues

How are you using Studio?

Legend Studio

Current and expected behavior

Our team is currently working with adding MongoDB support in legend.

The mongodb store workspace node has the header ###MongoDB.
Given the new studio functionality, we can write in text mode the mongodb workspace nodes, including the store, and we can compile it successfully.

Current behavior:
After compiling all the workspace nodes in text mode, it is not possible to go to form mode. When attempting to go back to form mode, all the workspace nodes disappear, unless they have already been pushed to gitlab, in which case they appear in text mode, but the store is being dropped.

Expected behavior:
After compiling all the workspace nodes in text mode, it should be possible to go to form mode.

Steps to reproduce

  • Start the Legend Engine on master branch, and start the SDLC and Studio (if you develop locally).
  • Create a new workspace or use an existing one in Studio.
  • Go into text mode and paste the workspace nodes from the Model Data below.
  • Click F9 to verify it compiles successfully.
  • Now you can either try to go to form mode directly, or push it to gitlab first and then go to form mode. Ideally you should try both flows, since if the workspace nodes aren't on gitlab they disappear, while if they are on gitlab they appear but drop the store workspace node.

Model data

###MongoDB
Database theo::test::store::mongodb::store::mydatabase
(
    Collection person
    (
        validationLevel: strict;
        validationAction: warn;
        jsonSchema: {
            "bsonType": "object",
            "title": "Record of Firm",
            "properties": {
                "firstName": {
                    "bsonType": "string",
                    "description": "firstName of the person",
                    "minLength": 2
                },
                "lastName": {
                    "bsonType": "string",
                    "description": "lastName of the person",
                    "minLength": 2
                },
                "age": {
                    "bsonType": "int",
                    "description": "age of the person",
                    "minLength": 2
                },
                "firm": {
                    "bsonType": "object",
                    "description": "firm of the person",
                    "properties": {
                        "legalName": {
                            "bsonType": "string",
                            "description": "legal name of the firm"
                        },
                        "address": {
                          "bsonType": "string",
                          "description": "address of the firm"
                        }
                    }
                }
            },
            "additionalProperties": false
        };
    )
)


###Service
Service theo::test::store::mongodb::service::PersonService
{
  pattern: '/api/allPersons';
  documentation: '';
  autoActivateUpdates: true;
  execution: Single
  {
    query: |theo::test::store::mongodb::domain::Person.all()->graphFetch(
      #{
        theo::test::store::mongodb::domain::Person{
          firstName,
          lastName,
          firm{
            legalName
          }
        }
      }#
    )->serialize(
      #{
        theo::test::store::mongodb::domain::Person{
          firstName,
          lastName,
          firm{
            legalName
          }
        }
      }#
    );
    mapping: theo::test::store::mongodb::mapping::TestPersonMapping;
    runtime: theo::test::store::mongodb::runtime::TestMongoDBRuntime;
  }
  testSuites:
  [
    testSuite_1:
    {
      tests:
      [
        test_1:
        {
          asserts:
          [
            assertion_1:
              EqualToJson
              #{
                expected : 
                  ExternalFormat
                  #{
                    contentType: 'application/json';
                    data: '[]';
                  }#;
              }#
          ]
        }
      ]
    }
  ]
}


###ExternalFormat
Binding theo::test::store::mongodb::binding::PersonCollectionBinding
{
  contentType: 'application/json';
  modelIncludes: [
    theo::test::store::mongodb::domain::Person,
    theo::test::store::mongodb::domain::Firm,
    theo::test::store::mongodb::domain::Address,
    theo::test::store::mongodb::domain::Country,
    theo::test::store::mongodb::domain::Car,
    theo::test::store::mongodb::domain::Manufacturer
  ];
}


###Pure
Class theo::test::store::mongodb::domain::Firm
{
  legalName: String[0..1];
  dateFounded: DateTime[1];
  industrySectors: String[*];
  address: theo::test::store::mongodb::domain::Address[1];
}

Association theo::test::store::mongodb::domain::Country_Manufacturer
{
  manufacturer: theo::test::store::mongodb::domain::Manufacturer[0..1];
  country: theo::test::store::mongodb::domain::Country[1];
}

Association theo::test::store::mongodb::domain::Person_Car
{
  person: theo::test::store::mongodb::domain::Person[1];
  car: theo::test::store::mongodb::domain::Car[1..*];
}

Association theo::test::store::mongodb::domain::Car_Manufacturer
{
  manufacturer: theo::test::store::mongodb::domain::Manufacturer[1];
  car: theo::test::store::mongodb::domain::Car[1];
}

Association theo::test::store::mongodb::domain::Person_Firm
{
  person: theo::test::store::mongodb::domain::Person[1];
  firm: theo::test::store::mongodb::domain::Firm[0..1];
}

Class theo::test::store::mongodb::domain::Country
{
  continent: String[0..1];
  countryCode: String[1];
}

Class theo::test::store::mongodb::domain::Person
{
  firstName: String[0..1];
  lastName: String[1];
  age: Integer[0..1];
  birthDate: DateTime[1];
  phoneNumber: String[1];
  otherPhoneNumbers: String[*];
  email: String[1];
  address: theo::test::store::mongodb::domain::Address[0..1];
}

Class theo::test::store::mongodb::domain::Address
{
  street: String[1];
  city: String[0..1];
  postalCode: String[1];
  country: theo::test::store::mongodb::domain::Country[0..1];
}

Class theo::test::store::mongodb::domain::Car
{
  model: String[1];
}

Class theo::test::store::mongodb::domain::Manufacturer
{
  name: String[0..1];
}


###Mapping
Mapping theo::test::store::mongodb::mapping::TestPersonMapping
(
  *theo::test::store::mongodb::domain::Person[Person]: MongoDB
  {
    ~mainCollection [theo::test::store::mongodb::store::mydatabase] person
    ~binding theo::test::store::mongodb::binding::PersonCollectionBinding
  }
)


###Connection
MongoDBConnection theo::test::store::mongodb::connection::testConnection
{
  database: userDatabase;
  store: theo::test::store::mongodb::store::mydatabase;
  serverURLs: [localhost:27017];
  authentication: # UserPassword {
    username: 'sa';
    password: SystemPropertiesSecret
    {
      systemPropertyName: 'mongo_pwd';
    };
  }#;
}

###Runtime
Runtime theo::test::store::mongodb::runtime::TestMongoDBRuntime
{
  mappings:
  [
    theo::test::store::mongodb::mapping::TestPersonMapping
  ];
  connections:
  [
    theo::test::store::mongodb::store::mydatabase:
    [
      connection_1: theo::test::store::mongodb::connection::testConnection
    ]
  ];
}

Environment

System
  macOS Ventura 13.3.1
Browser
  Google Chrome Version 113.0.5672.126 (Official Build) (arm64)
Binaries
  Yarn version 3.5.0

Possible solution and workaround

No response

Contribution

  • I would like to work on the fix for this issue
@github-actions github-actions bot added this to the Backlog milestone May 26, 2023
@akphi akphi self-assigned this May 26, 2023
@akphi akphi modified the milestones: Backlog, 10.0.0 May 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants