001/*
002 *  Copyright 2022 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.activities;
017
018import java.time.ZonedDateTime;
019import java.util.Map;
020
021import javax.jcr.RepositoryException;
022
023import org.ametys.core.user.UserIdentity;
024import org.ametys.plugins.repository.AmetysObject;
025import org.ametys.plugins.repository.AmetysObjectIterable;
026
027/**
028 * {@link AmetysObject} that can store activities
029 */
030public interface ActivityHolderAmetysObject extends ActivityHolder
031{
032    /**
033     * Returns the activity holder holding the activities
034     * @return the activity holder
035     * @throws RepositoryException if failed to get activity holder node
036     */
037    public ActivityHolder getActivityHolder() throws RepositoryException;
038    
039    public default AmetysObjectIterable<Activity> getActivities() throws RepositoryException
040    {
041        return getActivityHolder().getActivities();
042    }
043    
044    public default Activity addActivity(ActivityType type, Map<String, Object> parameters, String eventId) throws RepositoryException
045    {
046        return getActivityHolder().addActivity(type, parameters, eventId);
047    }
048    
049    public default Activity addActivity(ZonedDateTime date, ActivityType type, Map<String, Object> parameters, UserIdentity author, String eventId) throws RepositoryException
050    {
051        return getActivityHolder().addActivity(date, type, parameters, author, eventId);
052    }
053
054}