001/*
002 *  Copyright 2018 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.model.restrictions;
017
018import java.util.Arrays;
019import java.util.HashSet;
020import java.util.Set;
021
022/**
023 * Restrictions provided with a restricted model item.
024 */
025public class Restrictions
026{
027    /** Cannot read status. */
028    private boolean _cannotRead;
029    /** Cannot write status. */
030    private boolean _cannotWrite;
031    /** Read right ids. */
032    private Set<String> _readRightIds = new HashSet<>();
033    /** Read workflow step ids. */
034    private Set<String> _writeRightIds = new HashSet<>();
035    /** Write right ids. */
036    private Set<Integer> _readWorkflowfStepIds = new HashSet<>();
037    /** Write workflow step ids. */
038    private Set<Integer> _writeWorkflowfStepIds = new HashSet<>();
039    
040    /**
041     * Retrieves the cannot read status of the restrictions
042     * @return the cannot read
043     */
044    public boolean cannotRead()
045    {
046        return _cannotRead;
047    }
048    
049    /**
050     * Sets the cannot read status
051     * @param cannotRead the cannot read status to set
052     */
053    public void setCannotRead(boolean cannotRead)
054    {
055        _cannotRead = cannotRead;
056    }
057    
058    /**
059     * Retrieves the cannot write status of the restrictions
060     * @return the cannot write
061     */
062    public boolean cannotWrite()
063    {
064        return _cannotWrite;
065    }
066    
067    /**
068     * Sets the cannot write status
069     * @param cannotWrite the cannot write status to set
070     */
071    public void setCannotWrite(boolean cannotWrite)
072    {
073        _cannotWrite = cannotWrite;
074    }
075    
076    /**
077     * Retrieves the read rights identifiers
078     * @return the read rights identifiers
079     */
080    public Set<String> getReadRightIds()
081    {
082        return _readRightIds;
083    }
084    
085    /**
086     * Add identifiers for read rights
087     * @param readRightIds the read right identifiers to add
088     */
089    public void addReadRightIds(String... readRightIds)
090    {
091        this._readRightIds.addAll(Arrays.asList(readRightIds));
092    }
093    
094    /**
095     * Retrieves the write rights identifiers
096     * @return the write rights identifiers
097     */
098    public Set<String> getWriteRightIds()
099    {
100        return _writeRightIds;
101    }
102    
103    /**
104     * Add identifiers for write rights
105     * @param writeRightIds the write right identifiers to add
106     */
107    public void addWriteRightIds(String... writeRightIds)
108    {
109        _writeRightIds.addAll(Arrays.asList(writeRightIds));
110    }
111    
112    /**
113     * Retrieves the read workflow step identifiers
114     * @return the read workflow step identifiers
115     */
116    public Set<Integer> getReadWorkflowfStepIds()
117    {
118        return _readWorkflowfStepIds;
119    }
120    
121    /**
122     * Add identifiers for read workflow step
123     * @param readWorkflowfStepIds read workflow step identifiers to add
124     */
125    public void addReadWorkflowfStepIds(Integer... readWorkflowfStepIds)
126    {
127        _readWorkflowfStepIds.addAll(Arrays.asList(readWorkflowfStepIds));
128    }
129    
130    /**
131     * Retrieves the write workflow step identifiers
132     * @return the write workflow step identifiers
133     */
134    public Set<Integer> getWriteWorkflowfStepIds()
135    {
136        return _writeWorkflowfStepIds;
137    }
138    
139    /**
140     * Add identifiers for write workflow step
141     * @param writeWorkflowfStepIds write workflow step identifiers to add
142     */
143    public void addWriteWorkflowfStepIds(Integer... writeWorkflowfStepIds)
144    {
145        _writeWorkflowfStepIds.addAll(Arrays.asList(writeWorkflowfStepIds));
146    }
147}