Removing property from aspect and adding it in to direct type

cancel
Showing results for 
Search instead for 
Did you mean: 
dhrumilgosaliya
Member II

Removing property from aspect and adding it in to direct type

Jump to solution

Hi All,

I have created one custom content model. In that model I am passing one property to one aspect like this:
model.xml
<aspect name="ab:xyzAspect">
<title>xyz Aspect</title>
<properties>
<property name="ab:abc">
<title>abc</title>
<type>d:text</type>
</property>
</properties>
</aspect>


share.properties file:
aspect.model_xyzAspect=xyz Aspect
form.field.label.model.abc=abc

Also added below in proper tags in share-config.xml
<aspect name="ab:xyzAspect"/>
<show id="ab:abc" />
<field id="ab:abc" label-id="form.field.label.ab.abc"></field>

now after this I have made one document and given this aspect to it.
From share ui it is completely showing value with property and working fine.

But now requirment is changed and this property is directly on type and so I have changed the model according to it.
like:
model.xml
<type name="ab:mno">
<title>mno</title>
<parent>ab:abFunctions</parent>
<properties>
<property name="ab:abc">
<title>abc</title>
<type>d:text</type>
</property>
</properties>
</type>


share.properties file:
type.model_mno=mno
form.field.label.model.abc=abc

Also added below in proper tags in share-config.xml
<type name="ab:mno">
<show id="ab:abc" />
<field id="ab:abc" label-id="form.field.label.ab.abc"></field>
removed aspect from it.

 

After changing it in model I restarted my server and working fine for new documents but for the older documents its not opening edit properties field and shwoing this can not be viewed.
What should I do to avoid this and is it any possible solution that I can show properties for older documents?

Please help me in this.

Thanks,
Dhrumil

1 Solution

Accepted Solutions
abhinavmishra14
Advanced

Re: Removing property from aspect and adding it in to direct type

Jump to solution

As far as i know, if you move a property from aspect to type based property and remove aspect definition all together from content model, the properties on share ui won't show and fail to load the proprties due to Dictionary exception for existing nodes (if aspect was applied and property was already set). The error you are seeing is expected. For new nodes its not a problem anyway because they are created with new model change you made. 

From user's point of view it doesn't matter where you keep a property. To keep the things simple i would suggest to keep the aspect as is and instead mark that aspect as a mandatory aspect on type.

<type name="ab:mno">
......
 <mandatory-aspects>
   <aspect>ab:xyzAspect</aspect>
 </mandatory-aspects>
</type>	

If you were to remove the aspect definition for your specific use case, and if you have several nodes that holds the property and value from earlier defined aspect i.e. ab:xyzAspect and since property name is same that you are moving, you have to follow this type of approach consodering you want to preserve the already set property value. 

1- Create a temp aspect with a temp property

2- Copy property value (value from ab:abc) from existing aspect (ab:xyzAspect) to temp aspect's property and apply the aspect on all the existing nodes.

3- Remove aspect e.g. ab:xyzAspect from all the existing nodes

Now your previous aspect's (ab:xyzAspect) property (ab:abc) value is preserved on a temp aspect. 

4- Update the type definition with ab:abc as property, and remove ab:xyzAspect definition from content model.

5- Copy the earlier saved values from temp aspect's property to newly added property (type based) on all existing nodes.

6- Remove the temp aspect from all existing nodes. 

7- Remove the temp aspect definition from content model. 

Now ab:abc property on type will have the values that was originally saved. 

Note, you would have to write a cleanup script or use javascript-console to cleanup nodes.

~Abhinav
(ACSCE, AWS SAA, Azure Admin)

View solution in original post

1 Reply
abhinavmishra14
Advanced

Re: Removing property from aspect and adding it in to direct type

Jump to solution

As far as i know, if you move a property from aspect to type based property and remove aspect definition all together from content model, the properties on share ui won't show and fail to load the proprties due to Dictionary exception for existing nodes (if aspect was applied and property was already set). The error you are seeing is expected. For new nodes its not a problem anyway because they are created with new model change you made. 

From user's point of view it doesn't matter where you keep a property. To keep the things simple i would suggest to keep the aspect as is and instead mark that aspect as a mandatory aspect on type.

<type name="ab:mno">
......
 <mandatory-aspects>
   <aspect>ab:xyzAspect</aspect>
 </mandatory-aspects>
</type>	

If you were to remove the aspect definition for your specific use case, and if you have several nodes that holds the property and value from earlier defined aspect i.e. ab:xyzAspect and since property name is same that you are moving, you have to follow this type of approach consodering you want to preserve the already set property value. 

1- Create a temp aspect with a temp property

2- Copy property value (value from ab:abc) from existing aspect (ab:xyzAspect) to temp aspect's property and apply the aspect on all the existing nodes.

3- Remove aspect e.g. ab:xyzAspect from all the existing nodes

Now your previous aspect's (ab:xyzAspect) property (ab:abc) value is preserved on a temp aspect. 

4- Update the type definition with ab:abc as property, and remove ab:xyzAspect definition from content model.

5- Copy the earlier saved values from temp aspect's property to newly added property (type based) on all existing nodes.

6- Remove the temp aspect from all existing nodes. 

7- Remove the temp aspect definition from content model. 

Now ab:abc property on type will have the values that was originally saved. 

Note, you would have to write a cleanup script or use javascript-console to cleanup nodes.

~Abhinav
(ACSCE, AWS SAA, Azure Admin)