Class AasxPersistenceRecipe
java.lang.Object
de.iip_ecosphere.platform.support.aas.basyx.AbstractPersistenceRecipe
de.iip_ecosphere.platform.support.aas.basyx.AasxPersistenceRecipe
- All Implemented Interfaces:
de.iip_ecosphere.platform.support.aas.PersistenceRecipe
class AasxPersistenceRecipe extends AbstractPersistenceRecipe
Persistence recipe for AASX.
- Author:
- Holger Eichelberger, SSE
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classAasxPersistenceRecipe.RelationshipRepresents an AASX relationship. -
Field Summary
-
Constructor Summary
Constructors Constructor Description AasxPersistenceRecipe()Creates a recipe instance. -
Method Summary
Modifier and Type Method Description private voidaasToStream(ZipOutputStream out, DocumentBuilderFactory factory, TransformerFactory transformerFactory, de.iip_ecosphere.platform.support.aas.Aas aas, List<AasxPersistenceRecipe.Relationship> rels)Turns an AAS to stream.private DocumentcreateContentTypesXML(DocumentBuilderFactory factory)Creates the content types XML fromCONTENT_TYPES.private DocumentcreateRelsXML(DocumentBuilderFactory factory, List<AasxPersistenceRecipe.Relationship> rels)Creates the relationships XML from the relationships inrels.List<de.iip_ecosphere.platform.support.aas.Aas>readFrom(File file)private voidtextToStream(ZipOutputStream out, String text)Emits text file contents into the output stream.private StringtoFileName(String idShort)Turns an AAS name into a file-compatible name.voidwriteTo(List<de.iip_ecosphere.platform.support.aas.Aas> aas, File file)private voidxmlToStream(ZipOutputStream out, TransformerFactory transformerFactory, Document doc)Emits an XML document into the output streams.Methods inherited from class de.iip_ecosphere.platform.support.aas.basyx.AbstractPersistenceRecipe
addAsset, getSupportedFormats, isValidForWriting, transform
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
AASX
private static final de.iip_ecosphere.platform.support.FileFormat AASX -
CONTENT_TYPES
-
-
Constructor Details
-
AasxPersistenceRecipe
AasxPersistenceRecipe()Creates a recipe instance.
-
-
Method Details
-
writeTo
public void writeTo(List<de.iip_ecosphere.platform.support.aas.Aas> aas, File file) throws IOException- Throws:
IOException
-
toFileName
Turns an AAS name into a file-compatible name.- Parameters:
idShort- the short name- Returns:
- the transformed name
-
aasToStream
private void aasToStream(ZipOutputStream out, DocumentBuilderFactory factory, TransformerFactory transformerFactory, de.iip_ecosphere.platform.support.aas.Aas aas, List<AasxPersistenceRecipe.Relationship> rels) throws IOException, ParserConfigurationException, TransformerExceptionTurns an AAS to stream.- Parameters:
out- the output ZIP streamfactory- the XML document factorytransformerFactory- the XML transformer factoryaas- the AAS to be turned into the streamrels- the AAS-level relationships to be modified with an added relationship foraas- Throws:
IOException- in case that stream writing failsParserConfigurationException- in case that the XML parser configuration is erroneousTransformerException- in case that writing the XML through transformation fails
-
createContentTypesXML
private Document createContentTypesXML(DocumentBuilderFactory factory) throws ParserConfigurationExceptionCreates the content types XML fromCONTENT_TYPES.- Parameters:
factory- the XML document factory- Returns:
- the XML document containing the content types
- Throws:
ParserConfigurationException- in case that the XML parser configuration is erroneous
-
createRelsXML
private Document createRelsXML(DocumentBuilderFactory factory, List<AasxPersistenceRecipe.Relationship> rels) throws ParserConfigurationExceptionCreates the relationships XML from the relationships inrels.- Parameters:
factory- the XML document factoryrels- the relationships to emit- Returns:
- the XML document containing the relationships
- Throws:
ParserConfigurationException- in case that the XML parser configuration is erroneous
-
xmlToStream
private void xmlToStream(ZipOutputStream out, TransformerFactory transformerFactory, Document doc) throws TransformerExceptionEmits an XML document into the output streams.- Parameters:
out- the output streamtransformerFactory- the XML transformer factory to usedoc- the XML document to emit- Throws:
TransformerException- in case that writing the XML through transformation fails
-
textToStream
Emits text file contents into the output stream.- Parameters:
out- the output streamtext- the text to emit
-
readFrom
- Throws:
IOException
-