001/* 002 * Copyright 2023 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.cms.content.consistency; 017 018import java.time.ZonedDateTime; 019import java.util.Optional; 020 021import javax.jcr.Node; 022 023import org.ametys.cms.repository.SimpleIndexableAmetysObject; 024import org.ametys.core.user.UserIdentity; 025import org.ametys.plugins.repository.RepositoryConstants; 026 027/** 028 * Simple object representing the result of a consistency check. 029 */ 030public class ContentConsistencyResult extends SimpleIndexableAmetysObject<ContentConsistencyResultFactory> 031{ 032 /** JCR node type for content consistency result */ 033 public static final String CONTENT_CONSISTENCY_RESULT_NODETYPE = RepositoryConstants.NAMESPACE_PREFIX + ":consistencyResult"; 034 035 /** 036 * Creates an {@link ContentConsistencyResult}. 037 * @param node the node backing this result 038 * @param parentPath the parentPath in the Ametys hierarchy 039 * @param factory the factory which created the activity 040 */ 041 public ContentConsistencyResult(Node node, String parentPath, ContentConsistencyResultFactory factory) 042 { 043 super(node, parentPath, factory); 044 } 045 046 /** 047 * Get the content id 048 * @return the content Id 049 */ 050 public String getContentId() 051 { 052 return getValue(ContentConsistencyModel.CONTENT_ID); 053 } 054 055 /** 056 * Get the result date 057 * @return the date 058 */ 059 public ZonedDateTime getDate() 060 { 061 return getValue(ContentConsistencyModel.DATE); 062 } 063 064 /** 065 * Get the unauthorized count 066 * @return the count 067 */ 068 public long getUnauthorizedCount() 069 { 070 return getValue(ContentConsistencyModel.UNAUTHORIZED); 071 } 072 073 /** 074 * Get the unknown count 075 * @return the unknown count 076 */ 077 public long getUnknownCount() 078 { 079 return getValue(ContentConsistencyModel.UNKNOWN); 080 } 081 082 /** 083 * Get the success count 084 * @return the success count 085 */ 086 public long getSuccessCount() 087 { 088 return getValue(ContentConsistencyModel.SUCCESS); 089 } 090 091 /** 092 * Get the not found count 093 * @return the count 094 */ 095 public long getNotFoundCount() 096 { 097 return getValue(ContentConsistencyModel.NOT_FOUND); 098 } 099 100 /** 101 * Get the server error count 102 * @return the count 103 */ 104 public long getServerErrorCount() 105 { 106 return getValue(ContentConsistencyModel.SERVER_ERROR); 107 } 108 109 /** 110 * Get the title 111 * @return the title 112 */ 113 public String getTitle() 114 { 115 return getValue(ContentConsistencyModel.TITLE); 116 } 117 118 /** 119 * Get the content types 120 * @return the content types 121 */ 122 public String[] getContentTypes() 123 { 124 return getValue(ContentConsistencyModel.CONTENT_TYPES); 125 } 126 127 /** 128 * Get the creator 129 * @return the creator 130 */ 131 public UserIdentity getCreator() 132 { 133 return getValue(ContentConsistencyModel.CREATOR); 134 } 135 136 /** 137 * Get the creation date 138 * @return the content creation date 139 */ 140 public ZonedDateTime getCreationDate() 141 { 142 return getValue(ContentConsistencyModel.CREATION_DATE); 143 } 144 145 /** 146 * Get the last major validator 147 * @return the last major validator 148 */ 149 public Optional<UserIdentity> getLastMajorValidator() 150 { 151 return Optional.ofNullable(getValue(ContentConsistencyModel.LAST_MAJOR_VALIDATOR)); 152 } 153 154 /** 155 * Get the last major validation date 156 * @return the last content major validation date 157 */ 158 public ZonedDateTime getLastMajorValidationDate() 159 { 160 return getValue(ContentConsistencyModel.LAST_MAJOR_VALIDATION_DATE); 161 } 162 163 /** 164 * Get the last validator 165 * @return the last validator 166 */ 167 public Optional<UserIdentity> getLastValidator() 168 { 169 return Optional.ofNullable(getValue(ContentConsistencyModel.LAST_VALIDATOR)); 170 } 171 172 /** 173 * Get the last validation date 174 * @return the last content validation date 175 */ 176 public ZonedDateTime getLastValidationDate() 177 { 178 return getValue(ContentConsistencyModel.LAST_VALIDATION_DATE); 179 } 180 181 /** 182 * Get the last contributor 183 * @return the last contributor 184 */ 185 public UserIdentity getLastContributor() 186 { 187 return getValue(ContentConsistencyModel.LAST_CONTRIBUTOR); 188 } 189 190 /** 191 * Get the last modification date 192 * @return the content last modification date 193 */ 194 public ZonedDateTime getLastModificationDate() 195 { 196 return getValue(ContentConsistencyModel.LAST_MODIFICATION_DATE); 197 } 198 199 /** 200 * Get the workflow step 201 * @return the workflow step 202 */ 203 public long getWorkflowStep() 204 { 205 return getValue(ContentConsistencyModel.WORKFLOW_STEP); 206 } 207}