How to get duplecates in Alfresco?

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Active Member

How to get duplecates in Alfresco?

I have a task: "to get a duplicates (documents with same property value) from Alfresco database with count duplicates amounts". In MySql there will be something like that:

mysql> SELECT COUNT(*) AS repetitions, last_name, first_name
-> FROM cat_mailing
-> GROUP BY last_name, first_name
-> HAVING repetitions > 1

But I have read that "The CMIS query language in Alfresco does not support GROUP BY or HAVING." . Is there any query (in any supported language) to perform described task? Thank you!

 

UPD: for now I am counting in Java this way (redefining hashCode/equals for Form20Row)

Map<Form20Row, Form20Row> rowsMap =  results.stream().parallel().map(doc -> {
            Form20Row row = new Form20Row();
            String propMark = propertyHelper.getNodeProp(doc, NDBaseDocumentModel.PROP_MARK);
            row.setGroupName(systemMessages.getString("form20.nss.name"));
            row.setDocMark(propMark);
            row.setDupesNumber(1);
            return row;
        }).collect(Collectors.toConcurrentMap(form20Row -> form20Row, form20Row -> form20Row,
                (existing, replacement) ->  {
                    int count = existing.getDupesNumber();
                    existing.setDupesNumber(++count);
                    return existing;
                }));

 

3 Replies
Highlighted
Community Manager
Community Manager

Re: How to get duplecates in Alfresco?

Hi @iceja 

I see from StackOverflow that you've updated your question. I that approach working for you?

Thanks,

Digital Community Manager, Alfresco Software.
Problem solved? Click Accept as Solution!
Highlighted
Active Member

Re: How to get duplecates in Alfresco?

My approach was to calculate dupes in Java collection (of results)

Highlighted
Community Manager
Community Manager

Re: How to get duplecates in Alfresco?

Hi @iceja,

Thanks for the update.

Best wishes, 

Digital Community Manager, Alfresco Software.
Problem solved? Click Accept as Solution!