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.data.external; 017 018import java.util.Map; 019import java.util.Set; 020 021import org.ametys.plugins.repository.data.holder.ModelAwareDataHolder; 022import org.ametys.runtime.model.ModelItem; 023 024/** 025 * This interface represents a provider of externalizables data. 026 * 027 */ 028public interface ExternalizableDataProvider 029{ 030 /** 031 * Enumeration for externalizable data status 032 * 033 */ 034 public enum ExternalizableDataStatus 035 { 036 /** Status for a data for which the value to used is the local value */ 037 LOCAL, 038 /** Status for a data for which the value to used is the external value */ 039 EXTERNAL 040 } 041 042 /** 043 * Get the paths of data that can be valued externally or locally. 044 * @param dataHolder The externalizable data holder 045 * @return The paths of data that can be valued externally or locally 046 */ 047 public Set<String> getExternalizableDataPaths(ModelAwareDataHolder dataHolder); 048 049 /** 050 * Checks if the data of given model item is externalizable 051 * @param dataHolder The externalizable data holder 052 * @param modelItem the model item 053 * @return <code>true</code> if the data of given model item is externalizable, <code>false</code> otherwise 054 */ 055 public default boolean isDataExternalizable(ModelAwareDataHolder dataHolder, ModelItem modelItem) 056 { 057 return isDataExternalizable(dataHolder, modelItem, Map.of()); 058 } 059 060 /** 061 * Checks if the data of given model item is externalizable in the given context 062 * @param dataHolder The externalizable data holder 063 * @param modelItem the model item 064 * @param context the context that can be used to determine if the data is externalizable 065 * @return <code>true</code> if the data of given model item is externalizable, <code>false</code> otherwise 066 */ 067 public boolean isDataExternalizable(ModelAwareDataHolder dataHolder, ModelItem modelItem, Map<String, Object> context); 068}