Package com.simplicite.util.integration
Class FlowXML
- java.lang.Object
-
- com.simplicite.util.integration.FlowXML
-
- All Implemented Interfaces:
java.io.Serializable
public class FlowXML extends java.lang.Object implements java.io.Serializable
Simplicité XML flow.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
FlowXML.ZIPFile
ZIP file info with ZIP file and oredred list of configuration files names within the ZIP file
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CLEAR_CACHE_AFTER
Clear cache after processing modestatic java.lang.String
CLEAR_CACHE_BEFORE
Clear cache before processing modestatic java.lang.String
CLEAR_CACHE_BOTH
Clear cache before and after processing modestatic java.lang.String
CLEAR_CACHE_NONE
No clear cache mode
-
Constructor Summary
Constructors Constructor Description FlowXML()
Default constructorFlowXML(boolean atomic)
Deprecated, for removal: This API element is subject to removal in a future version.Atomic is not supported anymoreFlowXML(boolean atomic, java.lang.String clear)
Deprecated, for removal: This API element is subject to removal in a future version.Atomic is not supported anymoreFlowXML(byte[] zip)
Constructor.FlowXML(java.io.InputStream zis)
Constructor.FlowXML(java.io.InputStream is, java.lang.String origin)
Constructor.FlowXML(java.io.OutputStream out)
Constructor.FlowXML(java.io.OutputStream out, java.lang.String format, int flushSize, java.lang.String zipName)
Constructor.FlowXML(java.lang.String clear)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addObject(ObjectXML obj)
Add an XML object.void
addObject(ObjectDB obj, java.lang.String action)
Add an XML object with specified actionvoid
addObject(ObjectDB obj, java.lang.String action, boolean timestampFields, boolean inlineDocs)
Add an XML object with specified actionstatic java.io.File
buildModuleXML(Grant g, java.lang.String moduleName, java.io.File dir, boolean delete)
Build single XML module XML file from exploded filesvoid
clear()
Clear objects of flowvoid
close()
Close the output writerjava.lang.String
compare(Grant g, FlowXML origin, FlowXML flow, java.lang.String title1, java.lang.String title2)
Compare 2 flowsMessage
contains(ObjectDB object)
Return find = 0 if not found, 1 if same functional key but difference in data, 2 if equalsMessage
contains(java.lang.String object, DataXML data)
Return find = 0 if not found, 1 if same functional key but difference in data, 2 if equalsstatic java.lang.String
error(java.lang.String message)
Standard XML error messagestatic FlowXML
fromJSON(java.lang.String json)
Parse JSON flow string into an XML flowstatic FlowXML
fromJSON(org.json.JSONArray json)
Parse JSON flow into an XML flowstatic FlowXML
fromJSON(org.json.JSONObject json)
Parse JSON flow into an XML flowstatic FlowXML
fromYAML(java.lang.String yaml)
Parse YAML flow string into an XML flowbyte[]
getBytes()
XML flow as bytes arrayjava.lang.String
getClearCache()
Get clear cache modejava.util.Date
getEffectiveDate()
Get effective import datejava.lang.String
getExternalDir()
Get external directoryObjectXML
getFirstObject()
Get XML object at first indexjava.io.InputStream
getInputStream()
Deprecated.Use getXMLInputStreamjava.io.InputStream
getJSONInputStream()
Stream flow as JSON byte array input streamObjectXML
getLastObject()
Get XML object at last indexstatic java.io.File
getModuleZIPFileFromDir(Grant g, java.lang.String name, java.io.File dir)
Get clean ZIP file from a checkout directorystatic java.io.InputStream
getModuleZIPStreamFromDir(Grant g, java.lang.String name, java.io.File dir)
Get clean ZIP stream from a checkout directoryObjectXML
getObject(int i)
Get XML object at specified indexjava.util.List<ObjectXML>
getObjects()
Get all XML objects of flowint
getSize()
Get number of XML objects in flowjava.lang.String
getTempDir()
Get temporary directoryjava.io.InputStream
getXMLInputStream()
Stream flow as XML byte array input streamjava.io.InputStream
getYAMLInputStream()
Stream flow as YAML byte array input streamvoid
insertObject(ObjectXML obj, int index)
Insert an XML object at specified indexboolean
isAtomic()
Deprecated, for removal: This API element is subject to removal in a future version.void
remove(int i)
Remove object at specified indexvoid
removeTempDir()
Remove temporary directorystatic java.lang.String
result(java.lang.String message)
Get standard XML result messagevoid
setEffectiveDate(java.util.Date d)
Set effective import datevoid
setObjects(java.util.List<ObjectXML> list)
Set all XML objects of flowboolean
toFile(java.lang.String path)
Serialize as XML filejava.lang.StringBuilder
toJSON()
Serialize as JSON string builderjava.lang.StringBuilder
toJSON(boolean indent)
Serialize as JSON string builderorg.json.JSONObject
toJSONObject()
Serialize as JSON objectjava.lang.String
toString()
Serialize as XML stringjava.lang.StringBuilder
toXML()
Serialize as XML string builderjava.lang.StringBuilder
toXML(java.lang.String tab)
Serialize as XML string builderjava.lang.StringBuilder
toYAML()
Serialize as YAML string builderjava.io.File
toZIP(java.lang.String name)
Deprecated.Use toZIP with format and exploded flagjava.io.File
toZIP(java.lang.String name, java.lang.String format)
Deprecated.Use toZIP with format and exploded flagjava.io.File
toZIP(java.lang.String name, java.lang.String format, boolean exploded)
Serialize as ZIP archive file with documentsFlowXML.ZIPFile
toZIPFile(java.lang.String name, java.lang.String format, boolean exploded)
Serialize as ZIP archive file with documentsstatic java.lang.String
xmlFooter()
Get XML footerstatic java.lang.String
xmlHeader()
Get XML headerstatic java.lang.String
xmlHeader(boolean atomic, java.util.Date effectiveDate, java.lang.String clearCache)
Deprecated, for removal: This API element is subject to removal in a future version.static java.lang.String
xmlHeader(java.util.Date effectiveDate, java.lang.String clearCache)
Get XML header
-
-
-
Field Detail
-
CLEAR_CACHE_NONE
public static final java.lang.String CLEAR_CACHE_NONE
No clear cache mode- See Also:
- Constant Field Values
-
CLEAR_CACHE_BEFORE
public static final java.lang.String CLEAR_CACHE_BEFORE
Clear cache before processing mode- See Also:
- Constant Field Values
-
CLEAR_CACHE_AFTER
public static final java.lang.String CLEAR_CACHE_AFTER
Clear cache after processing mode- See Also:
- Constant Field Values
-
CLEAR_CACHE_BOTH
public static final java.lang.String CLEAR_CACHE_BOTH
Clear cache before and after processing mode- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FlowXML
public FlowXML()
Default constructor
-
FlowXML
@Deprecated(forRemoval=true, since="4.0") public FlowXML(boolean atomic)
Deprecated, for removal: This API element is subject to removal in a future version.Atomic is not supported anymore
-
FlowXML
@Deprecated(forRemoval=true, since="4.0") public FlowXML(boolean atomic, java.lang.String clear)
Deprecated, for removal: This API element is subject to removal in a future version.Atomic is not supported anymore
-
FlowXML
public FlowXML(java.lang.String clear)
Constructor.- Parameters:
clear
- One ofCLEAR_CACHE_*
constants
-
FlowXML
public FlowXML(java.io.InputStream is, java.lang.String origin) throws XMLException
Constructor.
Loads an input stream.- Parameters:
is
- Input streamorigin
- Flow origin- Throws:
XMLException
-
FlowXML
public FlowXML(byte[] zip) throws XMLException
Constructor.
Loads a ZIP byte array data which contains:- XML files to load in alphabetic order
- Attached documents
- Parameters:
zip
- ZIP byte array- Throws:
XMLException
-
FlowXML
public FlowXML(java.io.InputStream zis) throws XMLException
Constructor.
Load ZIP input stream which contains:- XML files to load in alphabetic order
- Attached documents
- Parameters:
zis
- ZIP input stream- Throws:
XMLException
-
FlowXML
public FlowXML(java.io.OutputStream out)
Constructor.
Used to export XML in a stream.- Parameters:
out
- Output stream
-
FlowXML
public FlowXML(java.io.OutputStream out, java.lang.String format, int flushSize, java.lang.String zipName)
Constructor.
Used to export flow in a stream.- Parameters:
out
- Output streamformat
- Integration.FORMAT_XML JSON or YAMLflushSize
- Flush buffer sizezipName
- Optional name to get a zipped result
-
-
Method Detail
-
close
public void close() throws java.io.IOException
Close the output writer- Throws:
java.io.IOException
-
getObject
public ObjectXML getObject(int i)
Get XML object at specified index- Parameters:
i
- Index- Returns:
- XML object
-
remove
public void remove(int i)
Remove object at specified index- Parameters:
i
- Index
-
getFirstObject
public ObjectXML getFirstObject()
Get XML object at first index- Returns:
- XML object
-
getLastObject
public ObjectXML getLastObject()
Get XML object at last index- Returns:
- XML object
-
getObjects
public java.util.List<ObjectXML> getObjects()
Get all XML objects of flow- Returns:
- XML objects list
-
setObjects
public void setObjects(java.util.List<ObjectXML> list)
Set all XML objects of flow- Parameters:
list
- XML objects list
-
getSize
public int getSize()
Get number of XML objects in flow- Returns:
- Number of XML objects in flow
-
clear
public void clear()
Clear objects of flow
-
isAtomic
@Deprecated(forRemoval=true, since="4.0") public boolean isAtomic()
Deprecated, for removal: This API element is subject to removal in a future version.
-
getExternalDir
public java.lang.String getExternalDir()
Get external directory- Returns:
- External directory
-
getTempDir
public java.lang.String getTempDir()
Get temporary directory- Returns:
- Temporay directory
-
getClearCache
public java.lang.String getClearCache()
Get clear cache mode- Returns:
- Clear cache mode
-
getEffectiveDate
public java.util.Date getEffectiveDate()
Get effective import date- Returns:
- Effective import date or null
-
setEffectiveDate
public void setEffectiveDate(java.util.Date d)
Set effective import date- Parameters:
d
- Effective import date
-
addObject
public void addObject(ObjectXML obj) throws java.io.IOException
Add an XML object. If the FlowXML has been constructed with an output stream, the object is flushed directly to keep the heap free.- Parameters:
obj
- XML object to add- Throws:
java.io.IOException
-
insertObject
public void insertObject(ObjectXML obj, int index)
Insert an XML object at specified index- Parameters:
obj
- XML object to insertindex
- Index
-
addObject
public void addObject(ObjectDB obj, java.lang.String action) throws java.io.IOException
Add an XML object with specified action- Parameters:
obj
- XML objectaction
- Action- Throws:
java.io.IOException
-
addObject
public void addObject(ObjectDB obj, java.lang.String action, boolean timestampFields, boolean inlineDocs) throws java.io.IOException
Add an XML object with specified action- Parameters:
obj
- XML objectaction
- ActiontimestampFields
- With timestamp fields (if applicable)inlineDocs
- With documents inlined data- Throws:
java.io.IOException
-
xmlHeader
public static java.lang.String xmlHeader()
Get XML header- Returns:
- XML header
-
xmlHeader
@Deprecated(forRemoval=true, since="4.0") public static java.lang.String xmlHeader(boolean atomic, java.util.Date effectiveDate, java.lang.String clearCache)
Deprecated, for removal: This API element is subject to removal in a future version.
-
xmlHeader
public static java.lang.String xmlHeader(java.util.Date effectiveDate, java.lang.String clearCache)
Get XML header- Parameters:
effectiveDate
- Optional effective import dateclearCache
- Optional clear cache mode- Returns:
- XML header
-
xmlFooter
public static java.lang.String xmlFooter()
Get XML footer- Returns:
- XML footer
-
result
public static java.lang.String result(java.lang.String message)
Get standard XML result message- Parameters:
message
- Result message- Returns:
- Standard XML fragment for result message
-
error
public static java.lang.String error(java.lang.String message)
Standard XML error message- Parameters:
message
- Error message- Returns:
- Standard XML fragment for error message
-
getInputStream
@Deprecated(forRemoval=false, since="4.0") public java.io.InputStream getInputStream()
Deprecated.Use getXMLInputStream
-
getXMLInputStream
public java.io.InputStream getXMLInputStream()
Stream flow as XML byte array input stream- Returns:
- XML byte array input stream
-
getJSONInputStream
public java.io.InputStream getJSONInputStream()
Stream flow as JSON byte array input stream- Returns:
- JSON byte array input stream
-
getYAMLInputStream
public java.io.InputStream getYAMLInputStream()
Stream flow as YAML byte array input stream- Returns:
- YAML byte array input stream
-
fromJSON
public static FlowXML fromJSON(java.lang.String json)
Parse JSON flow string into an XML flow- Parameters:
json
- JSON flow string- Returns:
- XML object
-
fromJSON
public static FlowXML fromJSON(org.json.JSONObject json)
Parse JSON flow into an XML flow- Parameters:
json
- JSON {objects:[...]}- Returns:
- XML flow
-
fromJSON
public static FlowXML fromJSON(org.json.JSONArray json)
Parse JSON flow into an XML flow- Parameters:
json
- JSON array of single objects- Returns:
- XML flow
-
fromYAML
public static FlowXML fromYAML(java.lang.String yaml)
Parse YAML flow string into an XML flow- Parameters:
yaml
- YAML object string- Returns:
- XML flow
-
getBytes
public byte[] getBytes()
XML flow as bytes array- Returns:
- bytes
-
toString
public java.lang.String toString()
Serialize as XML string- Overrides:
toString
in classjava.lang.Object
- Returns:
- XML string
-
toXML
public java.lang.StringBuilder toXML()
Serialize as XML string builder- Returns:
- XML string builder
-
toXML
public java.lang.StringBuilder toXML(java.lang.String tab)
Serialize as XML string builder- Parameters:
tab
- Optional tabulation- Returns:
- XML string builder
-
toJSON
public java.lang.StringBuilder toJSON()
Serialize as JSON string builder- Returns:
- JSON string builder
-
toJSON
public java.lang.StringBuilder toJSON(boolean indent)
Serialize as JSON string builder- Parameters:
indent
- Indent?- Returns:
- JSON string builder
-
toJSONObject
public org.json.JSONObject toJSONObject()
Serialize as JSON object- Returns:
- JSON string builder
-
toYAML
public java.lang.StringBuilder toYAML()
Serialize as YAML string builder- Returns:
- JSON string builder
-
toFile
public boolean toFile(java.lang.String path)
Serialize as XML file- Parameters:
path
- FIle path- Returns:
- True if file writing is successful
-
toZIP
@Deprecated(forRemoval=false, since="4.0") public java.io.File toZIP(java.lang.String name)
Deprecated.Use toZIP with format and exploded flag
-
toZIP
@Deprecated(forRemoval=false, since="4.0") public java.io.File toZIP(java.lang.String name, java.lang.String format) throws java.io.IOException
Deprecated.Use toZIP with format and exploded flag- Throws:
java.io.IOException
-
toZIP
public java.io.File toZIP(java.lang.String name, java.lang.String format, boolean exploded) throws java.io.IOException
Serialize as ZIP archive file with documents- Parameters:
name
- ZIP archive nameformat
- Format (one ofIntegration.FORMAT_*
constants)exploded
- Explode configuration file in per-object files- Returns:
- ZIP file in temporary directory (caller have to delete it after usage)
- Throws:
java.io.IOException
-
toZIPFile
public FlowXML.ZIPFile toZIPFile(java.lang.String name, java.lang.String format, boolean exploded) throws java.io.IOException
Serialize as ZIP archive file with documents- Parameters:
name
- ZIP archive nameformat
- Format (one ofIntegration.FORMAT_*
constants)exploded
- Explode configuration file in per-object files- Returns:
- ZIP file info with ZIP file in temporary directory (caller have to delete it after usage) and ordered list of configuration files within the ZIP file
- Throws:
java.io.IOException
-
removeTempDir
public void removeTempDir()
Remove temporary directory
-
compare
public java.lang.String compare(Grant g, FlowXML origin, FlowXML flow, java.lang.String title1, java.lang.String title2)
Compare 2 flows
-
contains
public Message contains(java.lang.String object, DataXML data)
Return find = 0 if not found, 1 if same functional key but difference in data, 2 if equals- Parameters:
object
- Object namedata
- Data to search- Returns:
- Message find + data
-
contains
public Message contains(ObjectDB object)
Return find = 0 if not found, 1 if same functional key but difference in data, 2 if equals- Parameters:
object
- Selected object- Returns:
- Message find + data
-
buildModuleXML
public static java.io.File buildModuleXML(Grant g, java.lang.String moduleName, java.io.File dir, boolean delete) throws java.io.IOException
Build single XML module XML file from exploded files- Parameters:
g
- GrantmoduleName
- Module namedir
- Base directory of moduledelete
- Delete exploded files?- Returns:
- XML file or null
- Throws:
java.io.IOException
-
getModuleZIPFileFromDir
public static java.io.File getModuleZIPFileFromDir(Grant g, java.lang.String name, java.io.File dir) throws java.io.IOException
Get clean ZIP file from a checkout directory- Parameters:
g
- Grantdir
- Checkout directory- Returns:
- ZIP file
- Throws:
java.io.IOException
-
getModuleZIPStreamFromDir
public static java.io.InputStream getModuleZIPStreamFromDir(Grant g, java.lang.String name, java.io.File dir) throws java.io.IOException
Get clean ZIP stream from a checkout directory- Parameters:
g
- Grantdir
- Checkout directory- Returns:
- ZIP stream
- Throws:
java.io.IOException
-
-