001/*
002 *  Copyright 2015 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.odf.xslt;
017
018import java.util.Map;
019
020import org.ametys.core.util.dom.AmetysAttribute;
021import org.ametys.odf.program.Container;
022import org.ametys.plugins.repository.AmetysObjectResolver;
023
024/**
025 * DOM layer on structure of {@link Container}.
026 */
027public class ContainerElement extends AbstractODFElement<Container>
028{
029    /**
030     * Constructor.
031     * @param container the underlying {@link Container}.
032     * @param depth Depth to SAX.
033     * @param parent Parent of the element
034     * @param resolver AmetysObjectResolver to find some elements by ID
035     */
036    public ContainerElement(Container container, int depth, AbstractODFElement<?> parent, AmetysObjectResolver resolver)
037    {
038        super(container, depth, parent, resolver);
039    }
040
041    @Override
042    public String getTagName()
043    {
044        return "container";
045    }
046    
047    @Override
048    protected Map<String, AmetysAttribute> _lookupAttributes()
049    {
050        Map<String, AmetysAttribute> result = super._lookupAttributes();
051        
052        result.put("title", new AmetysAttribute("title", "title", null, _object.getTitle(), this));
053        
054        double ects = _object.getEcts();
055        if (ects > 0)
056        {
057            result.put("ects", new AmetysAttribute("ects", "ects", null, String.valueOf(ects), this));
058        }
059        
060        return result;
061    }
062}