001/* 002 * Copyright 2020 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.repository.migration.jcr.data.repository; 017 018import java.util.Calendar; 019 020import javax.jcr.Node; 021 022import org.ametys.plugins.repository.data.repositorydata.ModifiableRepositoryData; 023import org.ametys.plugins.repository.data.repositorydata.impl.JCRRepositoryData; 024import org.ametys.plugins.repository.jcr.SimpleAmetysObject; 025 026/** 027 * Ametys object representing a version for migration. 028 */ 029public class VersionAmetysObject extends SimpleAmetysObject<VersionFactory> 030{ 031 /** The component ID attribute name */ 032 public static final String COMPONENT_ID = "componentId"; 033 034 /** The version number attribute name */ 035 public static final String VERSION_NUMBER = "versionNumber"; 036 037 /** The execution date attribute name */ 038 public static final String EXECUTION_DATE = "executionDate"; 039 040 /** The comment attribute name */ 041 public static final String COMMENT = "comment"; 042 043 /** The repository data */ 044 protected ModifiableRepositoryData _repositoryData; 045 046 /** 047 * Constructor. 048 * @param node the JCR Node. 049 * @param parentPath the parent path 050 * @param factory the corresponding factory. 051 */ 052 public VersionAmetysObject(Node node, String parentPath, VersionFactory factory) 053 { 054 super(node, parentPath, factory); 055 _repositoryData = new JCRRepositoryData(getNode()); 056 } 057 058 /** 059 * Get the component id. 060 * @return the component id 061 */ 062 public String getComponentId() 063 { 064 return _repositoryData.getString(COMPONENT_ID); 065 } 066 067 /** 068 * Set the component id. 069 * @param componentId the component id 070 */ 071 public void setComponentId(String componentId) 072 { 073 _repositoryData.setValue(COMPONENT_ID, componentId); 074 } 075 076 /** 077 * Get the version number. 078 * @return the version number 079 */ 080 public String getVersionNumber() 081 { 082 return _repositoryData.getString(VERSION_NUMBER); 083 } 084 085 /** 086 * Set the version number. 087 * @param versionNumber the version number 088 */ 089 public void setVersionNumber(String versionNumber) 090 { 091 _repositoryData.setValue(VERSION_NUMBER, versionNumber); 092 } 093 094 /** 095 * Get the execution date. 096 * @return the execution date 097 */ 098 public Calendar getExecutionDate() 099 { 100 return _repositoryData.getDate(EXECUTION_DATE); 101 } 102 103 /** 104 * Set the execution date. 105 * @param executionDate the execution date 106 */ 107 public void setExecutionDate(Calendar executionDate) 108 { 109 _repositoryData.setValue(EXECUTION_DATE, executionDate); 110 } 111 112 /** 113 * Get the comment. 114 * @return the comment 115 */ 116 public String getComment() 117 { 118 if (_repositoryData.hasValue(COMMENT)) 119 { 120 return _repositoryData.getString(COMMENT); 121 } 122 return null; 123 } 124 125 /** 126 * Set the comment. 127 * @param comment the comment 128 */ 129 public void setComment(String comment) 130 { 131 _repositoryData.setValue(COMMENT, comment); 132 } 133}