001/*
002 *  Copyright 2022 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.plugins.odfsync.pegase.ws;
017
018import org.apache.avalon.framework.service.ServiceException;
019import org.apache.avalon.framework.service.ServiceManager;
020
021import org.ametys.odf.program.Program;
022import org.ametys.plugins.odfsync.export.AbstractStructureComponent;
023import org.ametys.plugins.odfsync.export.ExportReport;
024import org.ametys.plugins.odfsync.pegase.ws.structure.PegaseProgramStructure;
025
026/**
027 * Component for Pegase export
028 */
029public class PegaseStructureComponent extends AbstractStructureComponent
030{
031    /** Avalon Role */
032    public static final String ROLE = PegaseStructureComponent.class.getName();
033    
034    /** The PegaseProgramStructure */
035    protected PegaseProgramStructure _pegaseProgramStructure;
036    
037    @Override
038    public void service(ServiceManager manager) throws ServiceException
039    {
040        super.service(manager);
041        _pegaseProgramStructure = (PegaseProgramStructure) manager.lookup(PegaseProgramStructure.ROLE);
042    }
043    
044    /**
045     * Get the Pegase export report of the program id
046     * @param program the program
047     * @return the Pegase export report
048     */
049    @Override
050    public ExportReport getExportReport(Program program)
051    {
052        ExportReport report = new ExportReport(program);
053        _pegaseProgramStructure.checkProgram(program, report);
054        report.setExportStructure(_pegaseProgramStructure);
055        return report;
056    }
057}