001/*
002 *  Copyright 2020 Anyware Services
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016package org.ametys.cms.data;
017
018import java.util.Collection;
019import java.util.HashSet;
020import java.util.Set;
021
022import org.ametys.cms.repository.ModifiableContent;
023import org.ametys.plugins.repository.data.holder.values.SynchronizationResult;
024
025/**
026 * Result of a content synchronization
027 */
028public class ContentSynchronizationResult extends SynchronizationResult
029{
030    private Set<ModifiableContent> _modifiedContents = new HashSet<>();
031    
032    /**
033     * Retrieves the contents that have been modified by invert relations management
034     * @return the contents that have been modified by invert relations management
035     */
036    public Set<ModifiableContent> getModifiedContents()
037    {
038        return _modifiedContents;
039    }
040    
041    /**
042     * Add contents to the list of contents that have been modified by invert relations management
043     * @param contents the contents to add
044     */
045    public void addModifiedContents(Collection<? extends ModifiableContent> contents)
046    {
047        _modifiedContents.addAll(contents);
048    }
049    
050    @Override
051    public void aggregateResult(SynchronizationResult result)
052    {
053        super.aggregateResult(result);
054        
055        if (result instanceof ContentSynchronizationResult)
056        {
057            _modifiedContents.addAll(((ContentSynchronizationResult) result).getModifiedContents());
058        }
059    }
060}