How to store and display a table of data inside vp using openAPI?

Hi guys
Im looking for a way to save and represent a grid data structue inside a vp project.
I tested Grid diagram and etl table but it seems in this diagrams, data (acctually rows of table) should be relate to a part of project like diagrams, elements or models and we cant save custom values in them while the data that i want to store in those tables has no relation to the project elements or diagrams ( consider saving a two dimensional array of some random strings )
Acctually i want to use vp as a place to store and display this data and i want a plugin to do this action for me ( by action i mean creation of needed diagrams and elements for saving and showing data)
Please also note that i want the view of data to be like a table or grid just like how Etl table or grid diagram looks.
Is this possible at all ? If yes, what kind of diagram and element should i use and does creation of them fully supports in the vp api ?
Thanks in advance

Hi Mamad,

Thank you for your post. Let me discuss your case with our engineer first. I will get back to you as soon as I can.

Best regards,
Jick Yeung

Hi Mamad,

The answer to your question can be split into two steps:

  1. Create a custom model to store the non-project data
  2. Use ETL to visualize the information

For step 1, you can define a ‘Generic Model’, which is a custom model, and to store the information through the use of tagged values. Here is the code example:

// SAVE
IGenericModel lLoginInfo = IModelElementFactory.createGenericModel();
lLoginInfo.setGenericModelType("LoginInformation"); // I categorize this GenericModel is a "Login Information"

ITaggedValueContainer lTaggedValues = IModelElementFactory.createTaggedValueContainer();
lLoginInfo.setTaggedValues(lTaggedValues);

ITaggedValue lConnectionString = lTaggedValues.createTaggedValue(); // create a tagged value to store Connection String
lConnectionString.setName("Connection String");
lConnectionString.setValue(...);

ITaggedValue lRepositoryName = lTaggedValues.createTaggedValue(); // create another tagged value to store RepositoryName
lRepositoryName.setName("Repository Name");
lRepositoryName.setValue(...);
// LOAD
IProject lProject = ...;
IModelElement[] lElements = lProject.toModelElementArray(IModelElementFactory.MODEL_TYPE_GENERIC_MODEL);
for (IModelElement lElement : lElements) {
    // find out the LoginInformation from project.
    if ("LoginInformation".equals(((IGenericModel) lElement).getGenericModelType())) {
        IGenericModel lLoginInformation = (IGenericModel) lElement;
        String lConnectionString = lLoginInformation.getTaggedValues().getTaggedValueByName("Connection String").getValue();
        String lRepositoryName = lLoginInformation.getTaggedValues().getTaggedValueByName("Repository Name").getValue();

    }
}

For step 2, please refer to the discussion here:

Hope this helps. Please feel free to contact us again if you have any questions.

Best regards,
Jick Yeung

1 Like

Thank you so much Jick :pray: :pray:
Your quides completely meet my needs but i still have a little problem
When i create the etl table and papulate it with my custom data, it does not show the data at first because its model element field is set on Built-in Model by default and i have to manually change it to Generic Model to show the data

I cant find any method to do this action automatically. Is it possible at all ?

Hi Mamad,

Your reply has been forwarded to our engineers to study. I will let you know when there is any news.

Best regards,
Jick Yeung

Hi Mamad,

Please try:

String myType = "ABC";

IDataTableQuery query1 = IModelElementFactory.instance().createDataTableQuery();
query1.setElementModelType(IModelElementFactory.MODEL_TYPE_GENERIC_MODEL);
query1.setConditions(IGenericModel.PROP_GENERIC_MODEL_TYPE+"="+"\""+myType+"\"");
lEtlTableModelElement.addQuery(query1);

Hope this helps.

Best regards,
Jick Yeung

1 Like

Yeah, this is exactly what I wanted :ok_hand:
Thank you so much :pray:

Hi Mamad,

You are welcome. :slight_smile:

Best regards,
Jick Yeung