Description of the general method of creating the initial object heirachry in DOMS based on a tree structure in a file system
General description
The goal of this document is to describe the work of transforming data files and accompanying metadata files in a tree structure on disk to a Content-Model less object tree in DOMS.
For this to be generic some assumptions needs to be taken:
- Data files and metadata files that belongs together have the same prefix
- Data files can be recognised by their file suffix.
- Checksum files is supposed to be represented as objects, but as a property of an object. They will thus be skipped as objects in the tree, but used for creation in the creation of the object they belong to.
General rules:
- Directories are treated as a "hasPart" relation to a new object.
- The name of the relation is the directory name
- The new object's label is the path of the directory.
- A data file is a file containing data. The actual data is stored outside DOMS.
- A metadata file is a file containing metadata. The file is stored inside DOMS.
- A grouping of files (files having a common prefix) is represented as a object with:
- Datastreams for each metadata file
- "hasFile" relations to data files
Pseudo code expressing the above rules
The following pseudo code is meant to express the above rules on a more formal basis.
void handleDir(myDir, domsParentObject) { thisDirObject = new Object(label = myDir.getName()); domsParentObject.addHasPart(object = thisDirObject, relationName = myDir.getPath()); for(dir in myDir.getDirectories()) { handleDir(dir, thisDirObject); } handleFiles(myDir.getFiles(), thisDirObject); } void handleFiles(myFiles, dirParentObject) { for(group in myFiles.groupByPrefix) { if(group.size == 1) { handleFile(group.get(0), dirParentObject); } else { addHasPart(group, dirParentObject); } } } void handleFile(file, parentObject) { if(file.isDataFile) { addHasFile(file, parentObject); } else { addDataStream(file, parentObject); } } void addHasPart(fileGroup, dirParentObject) { thisPartObject = new Object(label = fileGroup.getPrefix()); dirParentObject.addHasPart(object = thisPartObject, relationName = fileGroup.getPrefix()); for(file in fileGroup) { handleFile(file, thisPartObject); } }