0
votes

I am hoping someone has experienced this before.

I have a data model in Alfresco that defines a few types and a few aspects.

For example Type X has mandatory aspects A and B.

As part of developing my application on top, I need to add a new aspect to type X. But when I add my new mandatory aspect and deploy my amp model, all the existing data for type X will no longer show up in my new queries trying to join on aspect X.

Does anyone know a seamless way to fix this?

Ideally some script that could be run that would analyze the model, match type names, and apply any missing aspects to instances of that type. This way the model could evolve with one script to evolve the data, and all of our queries could evolve with the data model in a coherent path.

Here is an example...

So lets say we have this query for our type X

SELECT P:nameSpace:aspect.nameSpace.propertyA
 FROM nameSpace:typeX AS primary 
 JOIN nameSpace:aspect AS P:nameSpace:aspect
      ON primary.cmis:objectId=P:nameSpace:aspect.cmis:objectId

Anytime we make an object X we will always have the aspect applied since it is mandatory. Now a few weeks later we add mandatory aspect2. And we need property B from it...

SELECT P:nameSpace:aspect.nameSpace.propertyA, P:nameSpace:aspect2.nameSpace.propertyB
 FROM nameSpace:typeX AS primary 
 JOIN nameSpace:aspect AS P:nameSpace:aspect
      ON primary.cmis:objectId=P:nameSpace:aspect.cmis:objectId
 JOIN nameSpace:aspect2 AS P:nameSpace:aspect2
      ON primary.cmis:objectId=P:nameSpace:aspect2.cmis:objectId

Our query has evolved with our data model, but the old instances of typeX will not be returned since they do not have aspect2 applied yet. Our theory is we can run a script to apply the missing aspects without versioning; and seamlessly evolve our content with our application.

1
Could you post your query? This should not happen actually. - mitpatoliya
Really? We see it pretty regularly I believe. It's in the case where we make a bunch of object x and query with nonunion aspects. Then in the future when object x has a new mandatory aspect... And our queries now join, our old objects x don't have that aspect. I'll try to post an example in my question soon. - TheNorthWes
Thanks @mitpatoliya. I added an example - TheNorthWes

1 Answers

1
votes

Ok, I got your problem your query is kind of making it mandatory to have both the aspect on the content and that is why it is not showing up old contents as they do not have that new aspect B. I see two option to deal with it.

  1. You can create rule on root folder and using that add that aspect to all existing contents. That is pretty simple solution.
  2. You can modify your query in such a way that it accomodate old contents, may be through left inner join.(I am not good with queries :) )