Package org.ametys.skinfactory.model
Class SkinModelDAO
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.skinfactory.model.SkinModelDAO
-
- All Implemented Interfaces:
LogEnabled
,Component
,Serviceable
public class SkinModelDAO extends AbstractLogEnabled implements Serviceable, Component
Component for interact with a skin model
-
-
Field Summary
Fields Modifier and Type Field Description private static DateFormat
_DATE_FORMAT
private I18nUtils
_i18nUtils
private SkinModelsManager
_modelsManager
private SkinDAO
_skinDAO
private SkinFactoryComponent
_skinFactoryManager
private SkinEditionHelper
_skinHelper
private SkinsManager
_skinsManager
-
Constructor Summary
Constructors Constructor Description SkinModelDAO()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private Map<String,Object>
_getSkinProperty(Skin skin)
private List<Object>
_models2JsonObject()
private void
_unlinkModel(Skin skin)
boolean
applyModel(String skinId, String modelId)
Apply model to the skinprotected boolean
applyModel(Skin skin, String modelId)
Apply model to the skinMap<String,Object>
applyModelToAll(String modelId)
Apply the model to all its skinsvoid
delete(String modelId)
Delete a modelString
generateSkin(String skinId, String modelId)
Generate a new skin from a modelMap<String,Object>
getModel(String modelId)
Retrieve informations on a skinMap<String,Object>
getSkinsAndModels(boolean includeAbstract)
Retrieve the list of models and skins availableString
importModel(String modelName, String tmpDirPath)
Import a model from a zip fileboolean
modelExists(String modelId)
Determines if a model existsvoid
service(ServiceManager manager)
String
unlinkModel(String skinId, String modelId)
Unlink the skin from its model-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
_DATE_FORMAT
private static final DateFormat _DATE_FORMAT
-
_skinsManager
private SkinsManager _skinsManager
-
_modelsManager
private SkinModelsManager _modelsManager
-
_skinFactoryManager
private SkinFactoryComponent _skinFactoryManager
-
_skinHelper
private SkinEditionHelper _skinHelper
-
_i18nUtils
private I18nUtils _i18nUtils
-
-
Constructor Detail
-
SkinModelDAO
public SkinModelDAO()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getModel
public Map<String,Object> getModel(String modelId)
Retrieve informations on a skin- Parameters:
modelId
- The skin id- Returns:
- the informations of a skin
-
getSkinsAndModels
public Map<String,Object> getSkinsAndModels(boolean includeAbstract)
Retrieve the list of models and skins available- Parameters:
includeAbstract
- Should include abstract skins- Returns:
- a map of skins and models
-
_models2JsonObject
private List<Object> _models2JsonObject()
-
modelExists
public boolean modelExists(String modelId) throws ProcessingException
Determines if a model exists- Parameters:
modelId
- The model id- Returns:
- true if model exists.
- Throws:
ProcessingException
- if something goes wrong when retrieving the list of models
-
importModel
public String importModel(String modelName, String tmpDirPath) throws IOException
Import a model from a zip file- Parameters:
modelName
- The name of the new modeltmpDirPath
- the tmp dir path where the zip has been uploaded- Returns:
- The model name
- Throws:
IOException
- if something goes wrong when manipulating files
-
generateSkin
public String generateSkin(String skinId, String modelId) throws IOException, ProcessingException
Generate a new skin from a model- Parameters:
skinId
- The new skin idmodelId
- The model- Returns:
- An error message, or null on success
- Throws:
IOException
- if an error occurs when manipulating filesProcessingException
- if an exception occurred during the generation processs
-
applyModelToAll
public Map<String,Object> applyModelToAll(String modelId) throws IOException
Apply the model to all its skins- Parameters:
modelId
- The model id- Returns:
- The set of modified skins id
- Throws:
IOException
- if an error occurs when manipulating files
-
_getSkinProperty
private Map<String,Object> _getSkinProperty(Skin skin)
-
applyModel
public boolean applyModel(String skinId, String modelId) throws IOException
Apply model to the skin- Parameters:
skinId
- The skin idmodelId
- The id of model- Returns:
- true if the model was applyed successfully
- Throws:
IOException
- if an error occurs when manipulating files
-
applyModel
protected boolean applyModel(Skin skin, String modelId) throws IOException
Apply model to the skin- Parameters:
skin
- The skinmodelId
- The id of model- Returns:
- true if the model was applyed successfully
- Throws:
IOException
- if an error occurs when manipulating files
-
delete
public void delete(String modelId) throws IOException
Delete a model- Parameters:
modelId
- The model id- Throws:
IOException
- if an error occurs when manipulating files
-
unlinkModel
public String unlinkModel(String skinId, String modelId) throws IOException
Unlink the skin from its model- Parameters:
skinId
- The id of the skinmodelId
- The id of the model- Returns:
- An error code, or null on success
- Throws:
IOException
- If an error occurred while removing the link
-
_unlinkModel
private void _unlinkModel(Skin skin) throws IOException
- Throws:
IOException
-
-