Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Version History

« Previous Version 7 Next »

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:

  1. Directories are treated as a "hasPart" relation to a new object.
    1. The name of the relation is the directory name
    2. The new object's label is the path of the directory.
  2. A data file is a file containing data. The actual data is stored outside DOMS.
  3. A metadata file is a file containing metadata. The file is stored inside DOMS.
  4. A grouping of files (files having a common prefix) is represented as a object with:
    1. Datastreams for each metadata file
    2. "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.

In the codes, the methods:

  • groupByPrefix(): returns an object which groups files by their common prefix.
  • isDataFile(): returns a boolean telling if the given file is a datafile. 
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 groupByPrefix(myFiles)) {
    if(group.size == 1) {
      handleFile(group.get(0), dirParentObject);
    } else {
      addHasPart(group, dirParentObject);
    }
  }
}

void handleFile(file, parentObject) {
  if(isDataFile(file)) {
    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);
  }
}
 
  • No labels