001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.ade.postupload.shared;
029
030import org.opencms.util.CmsUUID;
031
032import java.util.HashSet;
033import java.util.LinkedHashMap;
034import java.util.Map;
035import java.util.Set;
036
037import com.google.gwt.user.client.rpc.IsSerializable;
038
039/**
040 * Runtime data bean for prefetching.<p>
041 *
042 * @since 8.0.0
043 */
044public class CmsPostUploadDialogBean implements IsSerializable {
045
046    /** Name of the used js variable. */
047    public static final String DICT_NAME = "postupload_dialog";
048
049    /**
050     * A map of the resources for which the properties should be edited, with the structure ids as keys and the resource
051     * paths as values.
052     */
053    private Map<CmsUUID, String> m_resources = new LinkedHashMap<CmsUUID, String>();
054
055    /** Ids of resources for which validation is required. */
056    private Set<CmsUUID> m_idsWithRequiredValidation = new HashSet<>();
057
058    /** Flag which controls whether the property configurations should be used. */
059    private boolean m_useConfiguration;
060
061    /** Flag to control if configured basic properties should be shown. */
062    private boolean m_addBasicProperties;
063
064    /** True if there  was an image among the uploaded resources. */
065    private boolean m_hasImage;
066
067    /**
068     * Default constructor for serialization.<p>
069     */
070    public CmsPostUploadDialogBean() {
071
072        // default constructor for serialization
073    }
074
075    /**
076     * Creates a new instance.<p>
077     *
078     * @param resources the map of resources for which the properties should be uploaded
079     * @param idsWithRequiredValidation structurei ids of resources for which validation is required
080     * @param hasImage true if there is an image among the resources
081     */
082    public CmsPostUploadDialogBean(
083        Map<CmsUUID, String> resources,
084        Set<CmsUUID> idsWithRequiredValidation,
085        boolean hasImage) {
086
087        m_resources.putAll(resources);
088        m_idsWithRequiredValidation = idsWithRequiredValidation;
089        m_hasImage = hasImage;
090    }
091
092    /**
093     * Gets the structure ids of resources for which validation is required.
094     *
095     * @return the structure ids of resources for which validation is required
096     */
097    public Set<CmsUUID> getIdsWithRequiredValidation() {
098
099        return m_idsWithRequiredValidation;
100    }
101
102    /**
103     * Returns the list of resource paths.<p>
104     *
105     * @return the list of resource paths
106     */
107    public Map<CmsUUID, String> getResources() {
108
109        return m_resources;
110    }
111
112    /**
113     * Checks if there was an image among the uploaded resources.
114     *
115     * @return  true if an image was uploaded
116     */
117    public boolean hasImage() {
118
119        return m_hasImage;
120    }
121
122    /**
123     * Returns true if the basic properties configured for the sitemap should be shown.
124     * @return true if the basic properties configured for the sitemap should be shown.
125     */
126    public boolean isAddBasicProperties() {
127
128        return m_addBasicProperties;
129    }
130
131    /**
132     * Returns true if the property configurations should be used.<p>
133     *
134     * @return true if the property configurations should be used
135     */
136    public boolean isUsePropertyConfiguration() {
137
138        return m_useConfiguration;
139
140    }
141
142    /**
143     * Set a flag, indicating if basic properties as configured in the sitemap are merged into the
144     * properties shown on file upload.
145     *
146     * @param addBasicProperties flag, indicating if basic properties as configured in the sitemap should be added
147     */
148    public void setAddBasicProperties(final boolean addBasicProperties) {
149
150        m_addBasicProperties = addBasicProperties;
151    }
152
153    /**
154     * Sets the map of resources for which the properties should be uploaded.<p>
155     *
156     * @param resources the map of resources for which the properties should be uploaded
157     */
158    public void setResources(Map<CmsUUID, String> resources) {
159
160        m_resources = resources;
161    }
162
163    /**
164     * Enables/disables use of the property configuration.<p>
165     *
166     * @param useConfiguration true if the property configuration should be used
167     */
168    public void setUsePropertyConfiguration(boolean useConfiguration) {
169
170        m_useConfiguration = useConfiguration;
171    }
172
173}