Skip to main content
17-Peridot
February 16, 2023
Solved

ImportSourceControlledEntities

  • February 16, 2023
  • 3 replies
  • 3066 views

Hello,

 

I've been building on a project to help with deployments of projects to QA/BV/Pilot/Prod instances after development has been completed.

 

The use case (which I haven't been able to find an alternative to, so if you have one please let me know) is that when you develop a larger project, you often end up with entities that gets deprecated.

If you have an especially large project, it can be annoying to have to manually clean up all other environments of these no longer used entities as you deploy your application.

 

The thought I had was that after using the ImportSourceControlledEntities function, I would delete any entities that were not imported from source control.

 

But when doing some tests I have run into issues with this error:

 

JavaException: java.lang.Exception: Import Failed: Unable to create group: [1,002] Data store integrity violation error: [Error occurred while accessing the model provider.]

 

It seems to me like it happens if the ImportSourceControlledEntities fails for whatever reason (mine has failed because of missing ThingShapes for example).

 

But when I read on the PTC help center, it says that any failure will make it so no entities are imported.

My understanding of the error message reading this support article is that this is due to entity id's have been saved in the database.

 

Either my understanding is incorrect, or there seems to be some bug here.

 

I am asking here before reaching out to PTC support, has anyone else had similar issues?

 

Thanks,

Jens

Best answer by nmutter

Hey,

 

1. for your project you should create an extension project. This results in a .zip file in the end which you can install first in QA and after validation in the next environments. The extension project can also only include .xml files (the ones you exported for Source Control). This is how we manage to keep the environments on a defined state. (It will also remove entities previously existing in your extension)

2. For you issue at hand you need to have a look into the persistence provider logs (e.g. PostgreSql) - if twx logs don't tell you. It may give you more information regarding what caused the error (like which insert into which table caused an issue).

3 replies

22-Sapphire I
February 21, 2023

Please reach out to PTC support.

Failed imports should do a full roll back and not leave 'artifacts' or 'ghost' items

jensc17-PeridotAuthor
17-Peridot
February 21, 2023

Hello @PaiChung,

 

I agree with you and I have opened a case. Let's see what we can find.

 

Thanks,

Jens

nmutter16-PearlAnswer
16-Pearl
February 21, 2023

Hey,

 

1. for your project you should create an extension project. This results in a .zip file in the end which you can install first in QA and after validation in the next environments. The extension project can also only include .xml files (the ones you exported for Source Control). This is how we manage to keep the environments on a defined state. (It will also remove entities previously existing in your extension)

2. For you issue at hand you need to have a look into the persistence provider logs (e.g. PostgreSql) - if twx logs don't tell you. It may give you more information regarding what caused the error (like which insert into which table caused an issue).

jensc17-PeridotAuthor
17-Peridot
February 21, 2023

Hello @nmutter,

 

#1: I have seen this used by PTC as well before, but I have not been able to find any documentation or recommendations on how to use it.

Would you happen to have any?

It seemed simple enough to add a metadata.xml file together with an Entities folder like so:

jensc_0-1676993804531.png

But if this is not "supported" by PTC, I'm hesitant to use it.

 

#2: We checked into the DB, although not the logs and found the entities there. But will do more investigation with PTC.

 

Thanks,

Jens

16-Pearl
February 21, 2023

The general documenation for extension is in the help center Best Practices for Packaging and Deploying ThingWorx Solutions . One point of it is 

Importing Composer-Created Entities 

It does create the structure via the Eclipse plugin. But in the end it is in the structure you showed (Entities folder and metadata.xml).

jensc17-PeridotAuthor
17-Peridot
February 21, 2023

Hello,

 

Some more information:

 

After looking into the model_index table in the platform database we noticed that the imported entities existed in the table.

The imported entities at this point did not show up in the composer.

We were thinking that perhaps they would appear as ghost entities, but running the ghost entities service nothing showed.

 

Then we restarted the platform and this caused the entities to show up in the composer.

 

I have started a case for this as it seems to me like perhaps there could be some issue with the import service (or I am just using it wongly).

Will update this post once we figure it out.

 

Thanks,

Jens