Class PersistentQueryConfigurationMarshaller
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
applyPersistentQueryOverrides
(org.jdom2.Document persistentQueryDocument, org.jdom2.Document overrideDocument) Applies values in the overrideDocument to the persistentQueryDocument.static String
Convert this persistent query into an XML String.static String
asXmlString
(Collection<PersistentQueryConfiguration> configurations) Convert the provided persistent queries into an XML stringstatic List<PersistentQueryConfiguration>
createFromXmlByteArray
(byte[] xmlBytes) Create a list of PersistentQueryConfiguration instances from a byte array containing XML.static List<PersistentQueryConfiguration>
createFromXmlFile
(String fileName) Create a list of PersistentQueryConfiguration instances from a file containing XML.static List<PersistentQueryConfiguration>
createFromXmlFile
(String persistentQueryFileName, String overrideFileName) Create a list of PersistentQueryConfiguration instances from a file containing persistent query XML configurations and, if provided, a file containing override XML configurations.static org.jdom2.Document
createXmlDocumentFromConfigurations
(Collection<PersistentQueryConfiguration> configurations, BiConsumer<Boolean, PersistentQueryConfiguration> contextCallback) Create a complete XMLDocument
containing details on a collection of PersistentQueryConfiguration instances.decodeTypeSpecificFieldsJson
(String typeSpecificFieldsJson) static String
encodeTypeSpecificFieldsJson
(Map<String, Object> typeSpecificFields) Encode a config's TypeSpecificFields as JSON.static boolean
isValidXmlText
(String value) static org.jdom2.Document
streamToDocument
(InputStream inputStream) Parses xml file read from the input stream.static void
writeXmlFromConfigurations
(Collection<PersistentQueryConfiguration> configurations, Writer outputWriter, BiConsumer<Boolean, PersistentQueryConfiguration> contextCallback) Write XML text resenting a collection of persistent query configurations to the specified Writer.
-
Constructor Details
-
PersistentQueryConfigurationMarshaller
public PersistentQueryConfigurationMarshaller()
-
-
Method Details
-
isValidXmlText
-
createFromXmlByteArray
public static List<PersistentQueryConfiguration> createFromXmlByteArray(byte[] xmlBytes) throws IOException, org.jdom2.JDOMException Create a list of PersistentQueryConfiguration instances from a byte array containing XML. The XML should have been created by the correspondingcreateXmlDocumentFromConfigurations(Collection,BiConsumer)
method. There are no guarantees on the type, mutability, serializability, or thread-safety of the returned List.- Parameters:
xmlBytes
- the byte array containing the XML- Returns:
- a List of PersistentQueryConfiguration instances
- Throws:
IOException
org.jdom2.JDOMException
-
createFromXmlFile
Create a list of PersistentQueryConfiguration instances from a file containing XML. The XML should have been created by the correspondingcreateXmlDocumentFromConfigurations(Collection,BiConsumer)
method. There are no guarantees on the type, mutability, serializability, or thread-safety of the returned List.- Parameters:
fileName
- the name of the file to read- Returns:
- a List of PersistentQueryConfiguration instances
-
createFromXmlFile
public static List<PersistentQueryConfiguration> createFromXmlFile(String persistentQueryFileName, String overrideFileName) Create a list of PersistentQueryConfiguration instances from a file containing persistent query XML configurations and, if provided, a file containing override XML configurations.The overrides may be a subset of the full query configs. The override configuration document must have a root
<PersistentQueryOverrideRoot>
element, and<PersistentQueryOverride>
child elements that will hold partial query configuration values. A<Serial>
element is required under both the the<PersistentQuery>
and the<PersistentQueryOverride>
element, and their values must match in order for a set of overrides to get applied to a query. If a persistent query configuration element exists in the override it will completely replace what is in the persistent query config. If that element is a complex structure such as<Schedule>
then the entire<Schedule>
element will be replaced. Overrides of specific parts of complex elements is not supported. If the overrideFileName is null or an empty string, no attempt will be made to apply any overrides.The XML should have been created by the corresponding
createXmlDocumentFromConfigurations(Collection,BiConsumer)
method. There are no guarantees on the type, mutability, serializability, or thread-safety of the returned List.- Parameters:
persistentQueryFileName
- the name of the persistent query file to readoverrideFileName
- the name of the override file to read- Returns:
- a List of PersistentQueryConfiguration instances
-
applyPersistentQueryOverrides
public static void applyPersistentQueryOverrides(org.jdom2.Document persistentQueryDocument, org.jdom2.Document overrideDocument) Applies values in the overrideDocument to the persistentQueryDocument. Overrides will be applied to the persistent query if the override has a<Serial>
element whose value matches the<Serial>
element in the persistent query. Consider the example below.Persistent Query XML fragment:
Persistent Query Override fragment:<PersistentQueryRoot> <PersistentQuery> <Serial>90125</Serial> <HeapSizeInGB>1.0</HeapSizeInGB> ... </PersistentQuery> </PersistentQueryRoot>
The override has a serial value of 90125, which matches that of the query, and so the resulting document will have a HeapSizeInGB value of 2.0.<PersistentQueryOverrideRoot> <PersistentQueryOverride> <Serial>90125</Serial> <HeapSizeInGB>2.0</HeapSizeInGB> ... </PersistentQueryOverride> </PersistentQueryOverrideRoot>
- Parameters:
persistentQueryDocument
- the document generated from a persistent query xml fileoverrideDocument
- the document generated from a persistent query override xml file
-
streamToDocument
Parses xml file read from the input stream. Throws only unchecked exceptions.- Parameters:
inputStream
- stream of data used to build JDOM Document.
-
asXmlString
Convert this persistent query into an XML String.- Returns:
- this persistent query represented as an XML string.
-
asXmlString
Convert the provided persistent queries into an XML string- Parameters:
configurations
- Persistent queries to convert- Returns:
- Persistent queries represented as an XML string
-
writeXmlFromConfigurations
public static void writeXmlFromConfigurations(@NotNull Collection<PersistentQueryConfiguration> configurations, Writer outputWriter, BiConsumer<Boolean, PersistentQueryConfiguration> contextCallback) Write XML text resenting a collection of persistent query configurations to the specified Writer.- Parameters:
configurations
- the PersistentQueryConfiguration instances to be writtenoutputWriter
- the Writer to use for the output
-
createXmlDocumentFromConfigurations
public static org.jdom2.Document createXmlDocumentFromConfigurations(@NotNull Collection<PersistentQueryConfiguration> configurations, BiConsumer<Boolean, PersistentQueryConfiguration> contextCallback) Create a complete XMLDocument
containing details on a collection of PersistentQueryConfiguration instances.- Parameters:
configurations
- the configurations to be added to the document- Returns:
- the XML document
-
encodeTypeSpecificFieldsJson
Encode a config's TypeSpecificFields as JSON. This method assumes they exist, that isDefaultPersistentQueryConfiguration.getTypeSpecificFields()
is not null. Only Primitive types, Strings, and Arrays of them are allowed. The map will be encoded with type informationFor example, a single floating point field would be encoded like this
"floatField": { "type": "float", "value": 2.3 }
While an array field would look like this"stringAField": { "type": "string[]", "value": [ "Cantaloupe", "Apple", "Bagel" ] }
- Parameters:
typeSpecificFields
- the map of objects to encode- Returns:
- a JSON string encoding the objects
-
decodeTypeSpecificFieldsJson
-