001/* 002 * Copyright 2016 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.workspaces.project.objects; 017 018import javax.jcr.Node; 019 020import org.ametys.plugins.repository.AmetysObject; 021import org.ametys.plugins.repository.AmetysRepositoryException; 022import org.ametys.plugins.repository.RepositoryConstants; 023import org.ametys.plugins.repository.data.ametysobject.ModifiableModelLessDataAwareAmetysObject; 024import org.ametys.plugins.repository.data.holder.ModifiableModelLessDataHolder; 025import org.ametys.plugins.repository.data.holder.impl.DefaultModifiableModelLessDataHolder; 026import org.ametys.plugins.repository.data.repositorydata.ModifiableRepositoryData; 027import org.ametys.plugins.repository.data.repositorydata.impl.JCRRepositoryData; 028import org.ametys.plugins.repository.jcr.DefaultTraversableAmetysObject; 029 030/** 031 * {@link AmetysObject} for storing a project category. 032 */ 033public class ProjectCategory extends DefaultTraversableAmetysObject<ProjectCategoryFactory> implements ProjectsTreeNode, ModifiableModelLessDataAwareAmetysObject 034{ 035 /** Project node type name. */ 036 public static final String NODE_TYPE = RepositoryConstants.NAMESPACE_PREFIX + ":projectCategory"; 037 038 private static final String __DATA_TITLE = "title"; 039 private static final String __DATA_DESCRIPTION = "description"; 040 041 /** 042 * Creates a {@link ProjectCategory}. 043 * @param node the node backing this {@link AmetysObject}. 044 * @param parentPath the parent path in the Ametys hierarchy. 045 * @param factory the {@link ProjectFactory} which creates the AmetysObject. 046 */ 047 public ProjectCategory(Node node, String parentPath, ProjectCategoryFactory factory) 048 { 049 super(node, parentPath, factory); 050 } 051 052 public ModifiableModelLessDataHolder getDataHolder() 053 { 054 ModifiableRepositoryData repositoryData = new JCRRepositoryData(getNode()); 055 return new DefaultModifiableModelLessDataHolder(_getFactory().getProjectDataTypeExtensionPoint(), repositoryData); 056 } 057 058 /** 059 * Retrieves the title. 060 * @return the title. 061 * @throws AmetysRepositoryException if an error occurs. 062 */ 063 public String getTitle() throws AmetysRepositoryException 064 { 065 return getValue(__DATA_TITLE); 066 } 067 068 /** 069 * Set the title. 070 * @param title the title. 071 * @throws AmetysRepositoryException if an error occurs. 072 */ 073 public void setTitle(String title) throws AmetysRepositoryException 074 { 075 setValue(__DATA_TITLE, title); 076 } 077 078 /** 079 * Retrieves the description. 080 * @return the description. 081 * @throws AmetysRepositoryException if an error occurs. 082 */ 083 public String getDescription() throws AmetysRepositoryException 084 { 085 return getValue(__DATA_DESCRIPTION); 086 } 087 088 /** 089 * Set the description. 090 * @param description the description. 091 * @throws AmetysRepositoryException if an error occurs. 092 */ 093 public void setDescription(String description) throws AmetysRepositoryException 094 { 095 setValue(__DATA_DESCRIPTION, description); 096 } 097}