001/*
002 *  Copyright 2010 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.contenttype;
017
018import org.ametys.runtime.model.ViewElement;
019
020/**
021 * A reference to a metadata definition.
022 * @deprecated Use {@link ViewElement} instead
023 */
024@Deprecated
025public class MetadataDefinitionReference extends AbstractMetadataSetElement
026{
027    private String _metadataName;
028    
029    private String _metadataSetName;
030    
031    /**
032     * Constructor.
033     * @param metadataName the metadata name.
034     */
035    public MetadataDefinitionReference(String metadataName)
036    {
037        this(metadataName, null);
038    }
039    
040    /**
041     * Constructor.
042     * @param metadataName the metadata name.
043     * @param metadataSetName for content metadatas, the metadata-set name.
044     */
045    public MetadataDefinitionReference(String metadataName, String metadataSetName)
046    {
047        _metadataName = metadataName;
048        _metadataSetName = metadataSetName;
049    }
050    
051    /**
052     * Retrieves the metadata name.
053     * @return the metadata name.
054     */
055    public String getMetadataName()
056    {
057        return _metadataName;
058    }
059
060    /**
061     * Set the metadata name.
062     * @param metadataName the metadata name.
063     */
064    public void setMetadataName(String metadataName)
065    {
066        _metadataName = metadataName;
067    }
068    
069    /**
070     * Retrieves the metadata-set name.
071     * @return the metadata-set name.
072     */
073    public String getMetadataSetName()
074    {
075        return _metadataSetName;
076    }
077    
078    /**
079     * Set the metadata-set name.
080     * @param metadataSetName the metadata-set name.
081     */
082    public void setMetadataSetName(String metadataSetName)
083    {
084        _metadataSetName = metadataSetName;
085    }
086    
087    @Override
088    public String toString()
089    {
090        StringBuilder metadataSet = new StringBuilder();
091        
092        metadataSet.append(_metadataName);
093        if (_metadataSetName != null)
094        {
095            metadataSet.append(" (").append(_metadataSetName).append(')');
096        }
097        metadataSet.append(" [");
098        metadataSet.append(getElements().size());
099        metadataSet.append("]");
100        
101        return metadataSet.toString();
102    }
103}