001/* 002 * Copyright 2012 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.program; 017 018import java.util.Collections; 019import java.util.List; 020 021import javax.jcr.Node; 022 023import org.ametys.cms.data.ContentDataHelper; 024import org.ametys.odf.cdmfr.CDMFRTagsConstants; 025import org.ametys.runtime.model.exception.UndefinedItemPathException; 026 027/** 028 * This class represent the root element of a program 029 */ 030public class Program extends AbstractProgram<ProgramFactory> 031{ 032 /** 033 * Constructor. 034 * @param node the JCR Node backing this Content. 035 * @param parentPath the parent path in the Ametys hierarchy. 036 * @param factory the corresponding {@link ProgramFactory}. 037 */ 038 public Program(Node node, String parentPath, ProgramFactory factory) 039 { 040 super(node, parentPath, factory); 041 } 042 043 @Override 044 public List<ProgramPart> getProgramPartParents() 045 { 046 return Collections.EMPTY_LIST; 047 } 048 049 // --------------------------------------------------------------------------------------// 050 // CDMfr 051 // --------------------------------------------------------------------------------------// 052 @Override 053 public String getCDMTagName() 054 { 055 return CDMFRTagsConstants.TAG_PROGRAM; 056 } 057 058 /** 059 * Get the degree 060 * @return the degree or null 061 */ 062 public String getDegree() 063 { 064 try 065 { 066 return ContentDataHelper.getContentIdFromContentData(this, DEGREE); 067 } 068 catch (UndefinedItemPathException e) 069 { 070 return null; // this attribute is not part of model 071 } 072 } 073}