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.cms.workflow.history;
017
018import java.util.ArrayList;
019import java.util.Date;
020import java.util.List;
021
022import org.ametys.core.user.UserIdentity;
023
024/**
025 * Object representing an element with a workflow
026 */
027public class ElementWithWorkflow
028{
029    private String _title;
030    private Date _creationDate;
031    private UserIdentity _creator;
032    private boolean _isVersionable;
033    private List<VersionInformation> _versions;
034    
035    /**
036     * The constructor for a no versionable element
037     * @param title the title
038     * @param creationDate the creation date
039     * @param creator the creator
040     */
041    public ElementWithWorkflow(String title, Date creationDate, UserIdentity creator)
042    {
043        this._title = title;
044        this._creationDate = creationDate;
045        this._creator = creator;
046        this._isVersionable = false;
047        this._versions = new ArrayList<>();
048    }
049    
050    /**
051     * The constructor for an versionable element
052     * @param title the title
053     * @param creationDate the creation date
054     * @param creator the creator
055     * @param versions the list of versions
056     */
057    public ElementWithWorkflow(String title, Date creationDate, UserIdentity creator, List<VersionInformation> versions)
058    {
059        this(title, creationDate, creator);
060        this._isVersionable = true;
061        this._versions = versions;
062    }
063    
064    /**
065     * Get the title of the element
066     * @return the title
067     */
068    public String getTitle()
069    {
070        return _title;
071    }
072    
073    /**
074     * Get the creation date of the element
075     * @return the creation date
076     */
077    public Date getCreationDate()
078    {
079        return _creationDate;
080    }
081    
082    /**
083     * Get the creator of the element
084     * @return the creator
085     */
086    public UserIdentity getCreator()
087    {
088        return _creator;
089    }
090    
091    /**
092     * <code>true</code> if the element is versionable
093     * @return <code>true</code> if the element is versionable
094     */
095    public boolean isVersionable()
096    {
097        return _isVersionable;
098    }
099    
100    /**
101     * The list of versions of the element
102     * @return the list of versions
103     */
104    public List<VersionInformation> getVersions()
105    {
106        return _versions;
107    }
108}