Class ModelRepository<M extends IModel>
- java.lang.Object
-
- net.ssehub.easy.basics.modelManagement.ModelRepository<M>
-
- Type Parameters:
M- the specific model type
- All Implemented Interfaces:
IModelManagementRepository<M>,IModelRepository<M>
class ModelRepository<M extends IModel> extends java.lang.Object implements IModelManagementRepository<M>, IModelRepository<M>
Implements the model repository interface by delegating toModelManagement. However, there are some methods that shall not directly be public inModelManagementand are, thus, hidden via delegation.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private ModelManagement<M>modelMgmt
-
Constructor Summary
Constructors Constructor Description ModelRepository(ModelManagement<M> modelMgmt)Creates a model repository.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearLocation(java.io.File file, ProgressObserver observer)Removes a file location, i.e.java.util.List<VersionedModelInfos<M>>getAvailable(java.lang.String name)Returns models available for a given modelname.ModelLocations.LocationgetLocationFor(java.net.URI uri)Returns the location foruri.ModelInfo<M>getModelInfo(java.lang.String name, Version version, java.net.URI uri)Returns a known model information object via its URI.ModelInfo<M>getResolvedModelInfo(M model)Returns the model information object for the given model by considering resolved models.booleanisOutdated(ModelInfo<M> info)Returns whether a model information is outdated.Mload(ModelInfo<M> info, java.util.List<IMessage> messages)Loads the model related toinfowith a new default import resolver.Mload(ModelInfo<M> info, ImportResolver<M> resolver, java.util.List<IMessage> messages)Loads the model related toinfowith the given import resolver.ModelLoaders<M>loaders()Returns the loaders.voidupdateForLoader(IModelLoader<M> loader, ProgressObserver observer)Registers a model loader and updates the model information provided by the loader.voidupdateModelInformation(java.io.File file, ProgressObserver observer)Updates the model information infile.
-
-
-
Field Detail
-
modelMgmt
private ModelManagement<M extends IModel> modelMgmt
-
-
Constructor Detail
-
ModelRepository
ModelRepository(ModelManagement<M> modelMgmt)
Creates a model repository.- Parameters:
modelMgmt- the model management instance to delegate to
-
-
Method Detail
-
getAvailable
public java.util.List<VersionedModelInfos<M>> getAvailable(java.lang.String name)
Description copied from interface:IModelRepositoryReturns models available for a given modelname.- Specified by:
getAvailablein interfaceIModelRepository<M extends IModel>- Parameters:
name- the name to search for- Returns:
- the available model or null
-
isOutdated
public boolean isOutdated(ModelInfo<M> info)
Description copied from interface:IModelRepositoryReturns whether a model information is outdated.- Specified by:
isOutdatedin interfaceIModelRepository<M extends IModel>- Parameters:
info- the object to be tested- Returns:
trueif it is outdated,falseelse
-
load
public M load(ModelInfo<M> info, java.util.List<IMessage> messages)
Description copied from interface:IModelRepositoryLoads the model related toinfowith a new default import resolver.- Specified by:
loadin interfaceIModelRepository<M extends IModel>- Parameters:
info- the model info to load the model formessages- the messages collected so far (modified as a side effect)- Returns:
- the loaded model or null
-
load
public M load(ModelInfo<M> info, ImportResolver<M> resolver, java.util.List<IMessage> messages)
Description copied from interface:IModelRepositoryLoads the model related toinfowith the given import resolver.- Specified by:
loadin interfaceIModelRepository<M extends IModel>- Parameters:
info- the model info to load the model forresolver- the import resolver to use (null for a new default resolver)messages- the messages collected so far (modified as a side effect)- Returns:
- the loaded model or null
-
getModelInfo
public ModelInfo<M> getModelInfo(java.lang.String name, Version version, java.net.URI uri)
Description copied from interface:IModelRepositoryReturns a known model information object via its URI.- Specified by:
getModelInfoin interfaceIModelRepository<M extends IModel>- Parameters:
name- the name of the model to search forversion- the version of the model to search foruri- the URI to search for- Returns:
- the related model information object (or null if not found)
-
updateModelInformation
public void updateModelInformation(java.io.File file, ProgressObserver observer) throws ModelManagementExceptionUpdates the model information infile.- Specified by:
updateModelInformationin interfaceIModelManagementRepository<M extends IModel>- Parameters:
file- the location folder to searchobserver- an optional progress observer (useProgressObserver.NO_OBSERVERbut not null in case that no observation is intended)- Throws:
ModelManagementException- in case that the available information may be come inconsistent due to this update
-
updateForLoader
public void updateForLoader(IModelLoader<M> loader, ProgressObserver observer) throws ModelManagementException
Registers a model loader and updates the model information provided by the loader.- Specified by:
updateForLoaderin interfaceIModelManagementRepository<M extends IModel>- Parameters:
loader- the model loader (must not be null)observer- an optional progress observer (useProgressObserver.NO_OBSERVERbut not null in case that no observation is intended)- Throws:
ModelManagementException- in case that theloaderaims at loading inconsistent information
-
getLocationFor
public ModelLocations.Location getLocationFor(java.net.URI uri)
Returns the location foruri.- Specified by:
getLocationForin interfaceIModelRepository<M extends IModel>- Parameters:
uri- the URI to search for- Returns:
- the related location
-
loaders
public ModelLoaders<M> loaders()
Returns the loaders.- Specified by:
loadersin interfaceIModelManagementRepository<M extends IModel>- Returns:
- the loaders
-
clearLocation
public void clearLocation(java.io.File file, ProgressObserver observer)Removes a file location, i.e. a location from where models can be loaded.- Specified by:
clearLocationin interfaceIModelManagementRepository<M extends IModel>- Parameters:
file- the file location (null is ignored)observer- an optional progress observer (useProgressObserver.NO_OBSERVERbut not null in case that no observation is intended)
-
getResolvedModelInfo
public ModelInfo<M> getResolvedModelInfo(M model)
Returns the model information object for the given model by considering resolved models.- Specified by:
getResolvedModelInfoin interfaceIModelManagementRepository<M extends IModel>- Parameters:
model- the model to search an information object for which resolvesmodel- Returns:
- the related model information object or null if there is none
-
-