Package jmri.jmrix.can.cbus.node
Class CbusNodeBackupManager
- java.lang.Object
-
- jmri.jmrix.can.cbus.node.CbusNodeBackupManager
-
public class CbusNodeBackupManager extends java.lang.Object
Class to work with CbusNode xml files Loosely based on Load and store the timetable data file: TimeTableData.xml
-
-
Field Summary
Fields Modifier and Type Field Description java.text.SimpleDateFormat
xmlDateStyle
-
Constructor Summary
Constructors Constructor Description CbusNodeBackupManager(CbusBasicNodeWithManagers node)
Create a new CbusNodeBackupManager
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
doLoad()
Full XML load.boolean
doStore(boolean createNew, boolean seenErrors)
Save the xml to user profile trims backup list as per user pref.java.util.ArrayList<CbusNodeFromBackup>
getBackups()
Get a list of all of the backups currently in the xml fileprotected boolean
getBackupStarted()
protected java.io.File
getFileLocation()
Get the XML File Locationjava.util.Date
getFirstBackupTime()
Get the time of first full backup for the Node.java.util.Date
getLastBackupTime()
Get the time of last full backup for the Node.int
getNumCompleteBackups()
CbusNodeConstants.BackupType
getSessionBackupStatus()
Get the current backup status for the Node.protected void
nodeInSLiM()
Add an xml entry advising Node in SLiM Modeprotected void
nodeNotOnNetwork()
Add an xml entry advising Node Not on Networkprotected boolean
removeNode(boolean rotate)
Remove Node XML Fileprotected void
resetBupArray()
Reset the backup array for testingprotected void
setBackupStarted(boolean started)
Set internal flag for backup started.protected void
setNodeInSlim()
-
-
-
Field Detail
-
xmlDateStyle
public final java.text.SimpleDateFormat xmlDateStyle
-
-
Constructor Detail
-
CbusNodeBackupManager
public CbusNodeBackupManager(CbusBasicNodeWithManagers node)
Create a new CbusNodeBackupManager- Parameters:
node
- the CbusNode which the xml is associated with
-
-
Method Detail
-
getBackups
public java.util.ArrayList<CbusNodeFromBackup> getBackups()
Get a list of all of the backups currently in the xml file- Returns:
- may be zero length if no backups
-
getNumCompleteBackups
public int getNumCompleteBackups()
-
getFirstBackupTime
@CheckForNull public java.util.Date getFirstBackupTime()
Get the time of first full backup for the Node.- Returns:
- value else null if unknown
-
getLastBackupTime
@CheckForNull public java.util.Date getLastBackupTime()
Get the time of last full backup for the Node.- Returns:
- value else null if unknown
-
doLoad
public final void doLoad()
Full XML load. Searches for XML file for the node and reads info Sets internal flag so can only be triggered once
-
doStore
public boolean doStore(boolean createNew, boolean seenErrors)
Save the xml to user profile trims backup list as per user pref.- Parameters:
createNew
- if true, creates a new backup then saves, false just savesseenErrors
- if true sets backup completed with errors, else logs as backup complete- Returns:
- true if all OK, else false if error occurred
-
nodeNotOnNetwork
protected void nodeNotOnNetwork()
Add an xml entry advising Node Not on Network
-
nodeInSLiM
protected void nodeInSLiM()
Add an xml entry advising Node in SLiM Mode
-
removeNode
protected boolean removeNode(boolean rotate)
Remove Node XML File- Parameters:
rotate
- if true, creates and rotates .bup files before delete, false just deletes the core node file- Returns:
- true on success, else false
-
getFileLocation
protected java.io.File getFileLocation()
Get the XML File Location- Returns:
- Location of the file, creating new if required
-
resetBupArray
protected void resetBupArray()
Reset the backup array for testing
-
getSessionBackupStatus
@Nonnull public CbusNodeConstants.BackupType getSessionBackupStatus()
Get the current backup status for the Node.- Returns:
- ENUM from CbusNodeConstants, e.g. BackupType.OUTSTANDING or BackupType.COMPLETE
-
setBackupStarted
protected void setBackupStarted(boolean started)
Set internal flag for backup started. Triggered within the backup script which is called from various places- Parameters:
started
- true if started
-
getBackupStarted
protected boolean getBackupStarted()
-
setNodeInSlim
protected void setNodeInSlim()
-
-