| java.lang.Object org.mmbase.util.xml.applicationdata.ContextDepthDataWriter
ContextDepthDataWriter | public class ContextDepthDataWriter (Code) | | This class is used to write (export) a selection of nodes to xml format.
The nodes to export are read from a XML context file, which specifies the
startnode and depth to which to parse.
The current version of this class combines a number of methods which we want to split - or at least share -
with a seperate class for handling contexts.
Note that because of it's static nature, no object instance need be made (in fact, none CAN be made) of this class.
since: MMBase-1.8 author: Daniel Ockeloen author: Jacco de Groot author: Pierre van Rooden version: $Id: ContextDepthDataWriter.java,v 1.5 2007/02/25 17:56:58 nklasens Exp $ |
Method Summary | |
static HashSet<Integer> | getFilterBuilders(List<Map<String, String>> filter, TypeDef bul) | static int | getRelatedNode(int nodeNumber, MMObjectNode relationNode) Determines the number of the node referenced by another node. | static int | getStartNode(XMLContextDepthReader capp, MMBase mmb) Retrieves the number of the startnode referenced by the context configuration file.. | static void | getSubNodes(int startnodenr, int maxdepth, HashSet<Integer> fb, HashSet<Integer> nodesdoneSet, HashSet<Integer> relationnodesSet, MMBase mmb) Searches the MMBase cloud, colelcting all nodes (and corresponmding relation nodes) that belong to a specific
type, and which can be traced up to a certain depth of nodes to a starting node.
Parameters: startnodenr - the number of the node to start with Parameters: maxdeoth - the maximum depth a tree is traversed. | static boolean | saveFile(String filename, String value) Saves a string value to a file. | static boolean | saveFile(String filename, byte[] value) Saves an array of byte to a file. | public static boolean | writeContext(ApplicationReader app, XMLContextDepthReader capp, String targetpath, MMBase mmb, Logger logger) Writes an application's nodes, according to that application's contexts, to a path.
The files written are stored in a subdirectory (named after the application), and contain the datasource (xml) files for
both datanodes and relation nodes.
Parameters: app - A ApplicationReader initialised to read the application's description (xml) fileThis object is used to retrieve what builder and relations are needed, and in which files data should be stored. Parameters: capp - A XMLContextDepthReader initialised to read the application's context fileThis object is used to retrieve information regarding search depth and starting nodes forthe search tree whoch determines what nodes are part of this application. Parameters: targetpath - The path where to save the application Parameters: mmb - Reference to the MMbase processormodule. | public static boolean | writeContextXML(XMLContextDepthReader capp, String filename) Writes the context file, based on what was supplied by the application
Parameters: capp - XMLContextDepthReader providing original context data Parameters: filename - Name of the xml file to save. | static void | writeDataSources(ApplicationReader app, HashSet<Integer> nodes, String targetpath, MMBase mmb, Logger logger) Writes the required datasources to their corresponding xml files by calling writeNodes()
Parameters: app - The ApplicationReader object, which is used to retrieve what datasources to write (and to what file). Parameters: nodes - The nodes that are part of the application. | static void | writeNodes(ApplicationReader app, HashSet<Integer> nodes, String targetpath, MMBase mmb, Logger logger, boolean isRelation) Writes the nodes to their corresponding xml files
Parameters: app - The ApplicationReader object, which is used to retrieve what sources to write (and to what file). Parameters: nodes - The nodes that are part of the application. | static void | writeRelationSources(ApplicationReader app, HashSet<Integer> nodes, String targetpath, MMBase mmb, Logger logger) Writes the required relation sources to their corresponding xml files by calling writeNodes()
Parameters: app - The ApplicationReader object, which is used to retrieve what relationsources to write (and to what file). Parameters: nodes - The relation nodes that are part of the application. |
getFilterBuilders | static HashSet<Integer> getFilterBuilders(List<Map<String, String>> filter, TypeDef bul)(Code) | | Retrieves the builders used for filtering the nodes for this application
Parameters: filter - Vector containign all the buildernames that are part of this applicationNote that being part of an application does not mean that they are exported! Parameters: bul - reference to the TypeDef builder, used for rertrieving builder types a HashSet , containing the types (Integer) of all builders part of this application. |
getRelatedNode | static int getRelatedNode(int nodeNumber, MMObjectNode relationNode)(Code) | | Determines the number of the node referenced by another node.
Parameters: nodeNumber - number of the referencing node Parameters: relationNode - node from the relationtable containing the relation data |
getStartNode | static int getStartNode(XMLContextDepthReader capp, MMBase mmb)(Code) | | Retrieves the number of the startnode referenced by the context configuration file..
Returns always only one node (should be changed?)
Parameters: capp - XMLContextDepthReader object for retrieving data from the context Parameters: mmb - reference to the MMBase object, used for retrieving aliases and builders An integer , the number of the startnode if succesful, -1 otherwise. |
getSubNodes | static void getSubNodes(int startnodenr, int maxdepth, HashSet<Integer> fb, HashSet<Integer> nodesdoneSet, HashSet<Integer> relationnodesSet, MMBase mmb)(Code) | | Searches the MMBase cloud, colelcting all nodes (and corresponmding relation nodes) that belong to a specific
type, and which can be traced up to a certain depth of nodes to a starting node.
Parameters: startnodenr - the number of the node to start with Parameters: maxdeoth - the maximum depth a tree is traversed. A depth of 0 or less means only the sdtartnode is added.A depth of one includes all teh nodes refernced by the startnode, etc.Relation nodes are not counted when determining 'depth'. Parameters: fb - a HashSet containing the set of types that are allowed for export Parameters: nodesdoneSet - A HashSet which holds all nodes that are already 'done' or 'almost done'. this set is expanded in the methodnodes already in this set are skipped (optimization). After return, the set has been expandedwith all nodes found while traversing the cloud Parameters: mmb - MMBase object used to retrieve builder information |
saveFile | static boolean saveFile(String filename, String value)(Code) | | Saves a string value to a file.
Parameters: filename - Name of the file to save. Parameters: value - string to store in the file True if succesfull, false if an error occurred. |
saveFile | static boolean saveFile(String filename, byte[] value)(Code) | | Saves an array of byte to a file.
Parameters: filename - Name of the file to save. Parameters: value - array to stiore in the file True if succesfull, false if an error occurred. |
writeContext | public static boolean writeContext(ApplicationReader app, XMLContextDepthReader capp, String targetpath, MMBase mmb, Logger logger)(Code) | | Writes an application's nodes, according to that application's contexts, to a path.
The files written are stored in a subdirectory (named after the application), and contain the datasource (xml) files for
both datanodes and relation nodes.
Parameters: app - A ApplicationReader initialised to read the application's description (xml) fileThis object is used to retrieve what builder and relations are needed, and in which files data should be stored. Parameters: capp - A XMLContextDepthReader initialised to read the application's context fileThis object is used to retrieve information regarding search depth and starting nodes forthe search tree whoch determines what nodes are part of this application. Parameters: targetpath - The path where to save the application Parameters: mmb - Reference to the MMbase processormodule. Used to retrieve the nodes to write. Parameters: logger - Storage for messages which can be displayed to the user. Returns true if succesful, false if no valid depth or startnode could be foundFailure of the export itself is not detected, though may be visible in the messages returned. throws: IOException - if one or more files could not be written |
writeContextXML | public static boolean writeContextXML(XMLContextDepthReader capp, String filename)(Code) | | Writes the context file, based on what was supplied by the application
Parameters: capp - XMLContextDepthReader providing original context data Parameters: filename - Name of the xml file to save. always true |
writeDataSources | static void writeDataSources(ApplicationReader app, HashSet<Integer> nodes, String targetpath, MMBase mmb, Logger logger)(Code) | | Writes the required datasources to their corresponding xml files by calling writeNodes()
Parameters: app - The ApplicationReader object, which is used to retrieve what datasources to write (and to what file). Parameters: nodes - The nodes that are part of the application. Those that are of a type compatible with the datasources are exported. Parameters: targetpath - Path where the xml files are written Parameters: mmb - MMBase object used to retrieve builder information Parameters: logger - Used to store messages that can be showmn to the user |
writeNodes | static void writeNodes(ApplicationReader app, HashSet<Integer> nodes, String targetpath, MMBase mmb, Logger logger, boolean isRelation)(Code) | | Writes the nodes to their corresponding xml files
Parameters: app - The ApplicationReader object, which is used to retrieve what sources to write (and to what file). Parameters: nodes - The nodes that are part of the application. Those that are of a type compatible with the sources are exported. Parameters: targetpath - Path where the xml files are written Parameters: mmb - MMBase object used to retrieve builder information Parameters: logger - Used to store messages that can be showmn to the user Parameters: isRelation - Indicates whether the nodes to write are data (false) or relation (true) nodes |
writeRelationSources | static void writeRelationSources(ApplicationReader app, HashSet<Integer> nodes, String targetpath, MMBase mmb, Logger logger)(Code) | | Writes the required relation sources to their corresponding xml files by calling writeNodes()
Parameters: app - The ApplicationReader object, which is used to retrieve what relationsources to write (and to what file). Parameters: nodes - The relation nodes that are part of the application. Those that are of a type compatible with the relationsources are exported. Parameters: targetpath - Path where the xml files are written Parameters: mmb - MMBase object used to retrieve builder information Parameters: logger - Used to store messages that can be showmn to the user |
|
|