001/*
002 *  Copyright 2011 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.enumeration;
017
018import org.apache.cocoon.environment.ObjectModelHelper;
019import org.apache.cocoon.environment.Request;
020import org.xml.sax.SAXException;
021
022import org.ametys.runtime.config.Config;
023
024/**
025 * Generate the list of mentions, according to a parameter "degree"
026 */
027public class MentionsGenerator extends OdfReferenceTableGenerator
028{
029    @Override
030    public void generate() throws SAXException
031    {
032        Request request = ObjectModelHelper.getRequest(objectModel);
033        String degree = request.getParameter("degree");
034        
035        contentHandler.startDocument();
036
037        if (degree != null)
038        {
039            if (degree.equals(Config.getInstance().getValue("odf.programs.degree.license")))
040            {
041                _refTableHelper.saxItems(contentHandler, OdfReferenceTableHelper.MENTION_LICENCE);
042            }
043            else if (degree.equals(Config.getInstance().getValue("odf.programs.degree.licensepro")))
044            {
045                _refTableHelper.saxItems(contentHandler, OdfReferenceTableHelper.MENTION_LICENCEPRO);
046            }
047            else if (degree.equals(Config.getInstance().getValue("odf.programs.degree.master")))
048            {
049                _refTableHelper.saxItems(contentHandler, OdfReferenceTableHelper.MENTION_MASTER);
050            }
051        }
052
053        contentHandler.endDocument();
054    }
055}