cancel
Showing results for 
Search instead for 
Did you mean: 

How to delete file link whose destination is NULL?

deepak1987
Star Contributor
Star Contributor
Hi,

I want to delete all file links whose destination is NULL. I tried through Lucene query to get all Links which is:
TYPE:"app:filelink" AND ISNULL:"cm:destination"

The above query doesn't work for me. It returns 0 rows.

The other approach is get all file links by TYPE:"app:filelink" in ResultSet and do iteration using for loop to check if destination is null, which is not the best way.

Please help me on this.
5 REPLIES 5

mitpatoliya
Star Collaborator
Star Collaborator
This will server your purpose I guess.

TYPE:"app:filelink" NOT ISNOTNULL:"cm:destination"

deepak1987
Star Contributor
Star Contributor
Hi Mittal,

Thanks for your reply. This query TYPE:"app:filelink" NOT ISNOTNULL:"cm:destination" didn't worked.  Smiley Sad

amandaluniz_z
Champ on-the-rise
Champ on-the-rise
Hi,

I'm not really familiar with links, but having a glance to the models in Alfresco, the one with the cm:destination is not app:filelink, but cm:link

So based on that, shouldn't the query look like the following?


TYPE:"cm:link" AND ISNULL:"cm:destination"

Regards,
Adei

deepak1987
Star Contributor
Star Contributor
Hi Adie,

Thanks for your reply.

My problem got resolved by creating fresh new indexesSmiley Very Happy  Smiley Very Happy

The below query will also work because cm:link is parent for app:filelink. But this query will return all File links as well as Folder links. If you want only filelinks then, use TYPE:"app:filelink" and for folderlinks use TYPE:"app:folderlink"

TYPE:"cm:link" AND ISNULL:"cm:destination"


Type cm:link is defined in contentModel.xml file as:

   
      <type name="cm:link">
         <title>Link Object</title>
         <parent>cm:cmobject</parent>
         <properties>
            <property name="cm:destination">
               <title>Link Destination</title>
               <type>d:noderef</type>
               <mandatory>true</mandatory>
            </property>
         </properties>
      </type>

Type app:filelink & app:folderlink are  defined in applicationModel.xml file as:

 
     <type name="app:filelink">
         <title>File Link Object</title>
         <parent>cm:link</parent>
      </type>
     
      <type name="app:folderlink">
         <title>Folder Link Object</title>
         <parent>cm:link</parent>
      </type>

So, to find all links whose destination is NULL, Execute any of the below queries:


// Returns only File links whose destination is NULL.
1) TYPE:"app:filelink" AND ISNULL:"cm:destination"

2) TYPE:"app:filelink" AND NOT ISNOTNULL:"cm:destination"

3) TYPE:"app:filelink" AND ISUNSET:"cm:destination"

// Returns only Folder links whose destination is NULL.
1) TYPE:"app:folderlink" AND ISNULL:"cm:destination"

2) TYPE:"app:folderlink" AND NOT ISNOTNULL:"cm:destination"

3) TYPE:"app:folderlink" AND ISUNSET:"cm:destination"

// Returns all File links & Folder links whose destination is NULL.
1) TYPE:"cm:link" AND ISNULL:"cm:destination"

2) TYPE:"cm:link" AND NOT ISNOTNULL:"cm:destination"

3) TYPE:"cm:link" AND ISUNSET:"cm:destination"

Thanks once again.

amandaluniz_z
Champ on-the-rise
Champ on-the-rise
True! didn't check the parent for the app:filelink…