Class XmlConnector
- java.lang.Object
-
- net.ssehub.easy.producer.core.persistence.internal.xml.XmlConnector
-
- All Implemented Interfaces:
StorageConnector
public class XmlConnector extends java.lang.Object implements StorageConnector
This class implements a StorageConnector for XML-file-based storages.- Author:
- Kapeluch, El-Sharkawy
-
-
Field Summary
Fields Modifier and Type Field Description private PathEnvironmentpathEnvprivate java.lang.StringxmlFilePath
-
Constructor Summary
Constructors Constructor Description XmlConnector(java.lang.String xmlFilePath, PathEnvironment pathEnv)Sole constructor for this class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidappendAttribute(java.lang.StringBuffer xml, java.util.Map.Entry<java.lang.String,java.lang.String> attr)Appends a given attribute to an existing xml String.private voidcreateEntities(org.w3c.dom.Node node, Model model)private org.w3c.dom.DocumentcreateXMLDocument()Creates an object model for the xml document, which should be parsed.PathEnvironmentgetPathEnvironment()Returns the path environment used for making paths relative.java.lang.StringgetProjectID()Returns the UUID of a given pl project.private java.lang.StringgetXmlFromEntity(Entity entity, java.lang.String indent)Returns xml-formatted string from given entity.voidloadModels(Model... models)Loads the specified models.voidloadModels(PersistentProject project)Method for loading models out of a persistent file/database.voidsaveModels(PersistentProject project)Saves data from given model to storage.
-
-
-
Field Detail
-
xmlFilePath
private java.lang.String xmlFilePath
-
pathEnv
private PathEnvironment pathEnv
-
-
Constructor Detail
-
XmlConnector
public XmlConnector(java.lang.String xmlFilePath, PathEnvironment pathEnv)Sole constructor for this class.- Parameters:
xmlFilePath- The absolute path for retrieving the xml configuration file.pathEnv- a path environment for making files and paths relative
-
-
Method Detail
-
loadModels
public void loadModels(PersistentProject project) throws PersistenceException
Description copied from interface:StorageConnectorMethod for loading models out of a persistent file/database.- Specified by:
loadModelsin interfaceStorageConnector- Parameters:
project- APersistentProjectholding an empty array ofModelsfor storing the information read in a persistent file/database. These models must only contain the correctModelTypes, for managing which parts should be loaded.- Throws:
PersistenceException- Will be thrown if an error is occurred during reading the persistent information.
-
loadModels
public void loadModels(Model... models) throws PersistenceException
Description copied from interface:StorageConnectorLoads the specified models.- Specified by:
loadModelsin interfaceStorageConnector- Parameters:
models- the models to load- Throws:
PersistenceException- in case of reading errors
-
createXMLDocument
private org.w3c.dom.Document createXMLDocument() throws PersistenceExceptionCreates an object model for the xml document, which should be parsed.- Returns:
- A new DOM Document object.
- Throws:
PersistenceException- If an error occurred while parsing the xml document.
-
createEntities
private void createEntities(org.w3c.dom.Node node, Model model)- Parameters:
node- the node within the current xml document representing the given model.model- The model related to the given node for saving the read entities.- Since:
- 14.09.2011
-
saveModels
public void saveModels(PersistentProject project) throws PersistenceException
Description copied from interface:StorageConnectorSaves data from given model to storage.- Specified by:
saveModelsin interfaceStorageConnector- Parameters:
project- The information which should be saved in non ivml files.- Throws:
PersistenceException- Will be thrown if an error is occurred during reading the persistent information.
-
getXmlFromEntity
private java.lang.String getXmlFromEntity(Entity entity, java.lang.String indent)
Returns xml-formatted string from given entity.- Parameters:
entity- The entity to generate xml-code fromindent- The indent of the current level- Returns:
- XML-string
- Since:
- 22.09.2011
-
appendAttribute
private void appendAttribute(java.lang.StringBuffer xml, java.util.Map.Entry<java.lang.String,java.lang.String> attr)Appends a given attribute to an existing xml String.- Parameters:
xml- The xml string, which should be extendedattr- The attribute, which should be inserted into the xml string.
-
getProjectID
public java.lang.String getProjectID()
Description copied from interface:StorageConnectorReturns the UUID of a given pl project.- Specified by:
getProjectIDin interfaceStorageConnector- Returns:
- the id or null if the specified project has no configuration file.
-
getPathEnvironment
public PathEnvironment getPathEnvironment()
Description copied from interface:StorageConnectorReturns the path environment used for making paths relative.- Specified by:
getPathEnvironmentin interfaceStorageConnector- Returns:
- the path environment
-
-