001/*
002 *  Copyright 2025 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.plugins.repository.trash;
017
018import java.util.Set;
019
020import org.ametys.plugins.repository.AmetysObject;
021import org.ametys.plugins.repository.data.ametysobject.ModifiableModelAwareDataAwareAmetysObject;
022import org.ametys.plugins.repository.jcr.JCRTraversableAmetysObject;
023
024/**
025 * An {@link AmetysObject} that represents an other {@link AmetysObject} that was trashed
026 */
027public interface TrashElement extends JCRTraversableAmetysObject, ModifiableModelAwareDataAwareAmetysObject
028{
029    /**
030     * Get the id of the trashed Ametys object
031     * @return the id
032     */
033    String getAmetysObjectId();
034
035    /**
036     * Get the trash element that represent one of the linked objects (see {@link #addLinkedObjects}) of this element
037     * @param hiddenOnly true to only retrieve the hidden elements
038     * @return the linked elements
039     */
040    Set<TrashElement> getLinkedElement(boolean hiddenOnly);
041    
042    /**
043     * Add the objects to the list of objects whose thrashing was related to the trashing
044     * of this element's object. If an element representing these linked objects in the trash
045     * is present during restoration or deletion of the current element, they should be restored/deleted
046     * at the same time.
047     * @param linkedObjectsIds a list of Ametys object ids
048     */
049    void addLinkedObjects(String... linkedObjectsIds);
050
051    /**
052     * Set the hidden status of the trash element.<br>
053     * 
054     * An element should be hidden if it was trashed because an other object
055     * was trashed.<br>
056     * Hidden element should not be visible when listing the trash elements,
057     * and should be restored or permanently deleted along with the element that
058     * triggered the thrashing
059     * @param hidden true to set hidden
060     */
061    void setHidden(boolean hidden);
062}