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.ODFHelper; 022import org.ametys.odf.course.Course; 023 024/** 025 * DOM layer on structure of {@link Course}. 026 */ 027public class CourseElement extends AbstractODFElement<Course> 028{ 029 /** 030 * Constructor. 031 * @param course the underlying {@link Course}. 032 * @param depth Depth to SAX. 033 * @param parent Parent of the element 034 * @param odfHelper ODFHelper to resolve children easily 035 */ 036 public CourseElement(Course course, int depth, CourseListElement parent, ODFHelper odfHelper) 037 { 038 super(course, depth, parent, odfHelper); 039 } 040 041 @Override 042 public String getTagName() 043 { 044 return "course"; 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 result.put("id", new AmetysAttribute("id", "id", null, _object.getId(), this)); 054 result.put("code", new AmetysAttribute("code", "code", null, _object.getCode(), this)); 055 result.put("name", new AmetysAttribute("name", "name", null, _object.getName(), this)); 056 057 String parentPath = _object.getContextPath(); 058 if (parentPath != null) 059 { 060 result.put("path", new AmetysAttribute("path", "path", null, parentPath + "/" + _object.getName() + "-" + _object.getCode(), this)); 061 } 062 063 return result; 064 } 065}