wiki:GritsEntryProperty

Entry and Property Object Model

Entry

An instance of the entry class corresponds to an item on the project manager hierarchy. All items share a common entry class that does not change independent of the type of item. Any information specific for a type of item is stored in the property class.

Each entry contains:

  • Instance of its parent entry (null for the root entry)
  • List of child entries
  • Name of the entry (displayed in the project explorer)
  • Property object with the specific information for an entry
  • Creation date

Property

Property classes store the information that is specific for each item in the project tree. Each entry has a single property member variable. The property is thereby an abstract class that is shared by all types of properties. Each property has a property type (String) which is a unique identifier for each property class. It is recommended to use edu.uga.ccrc.simiantools.entry as the start of the ID and append the entry type.

As part of the main application there are two property classes:

  • WorkspaceProperty
  • ProjectProperty

WorkspaceProperty is a helper class that gets automatically created the moment a workspace is opened. The entry with this property serves as the parent for all project entries (root of the tree) and does not have a parent itself. It only contains the path of the workspace in the file system (location).

ProjectProperty is the property class for a project entry. It contains:

  • Creator of the entry
  • Description
  • Creation time of the project
  • Last modification time of the project
  • A boolean flag indicating if the project is opened

DataModelHandler

The DatamodelHandler is a class that serves a container and management interface for the data model. The class is a singleton and a instance can be accessed by calling the static method DataModelHandler.instance().

The class contains a single Entry which contains a WorkspaceProperty and is the root entry for all projects. The handler also contains a list of DataModelChangeListener’s which allows other classes or plugins to register and be notified for changes to the data model:

  • Add a new entry
  • Remove an entry

Access to the data model

Any plugin can get access to the data model using the PropertyHandler, which stores the singleton of the DataModelHandler. Simply call PropertyHandler.getDataModel().

Serialization and De-serialization

All entries of a single project (direct child entries of the root entry) get serialized into the .project.xml file in the project folder. The file has the following format:

<?xml version="1.0" encoding="UTF-8"?>
<project>
    <entry type="project" id="0" name="My project">
        <entry type="sample" id="1" name="My sample" />
    </entry>
    <property id="0">
        ...
    </property>
    <property id="1">
        ...
    </property>
</project>

The file starts with a single entry tag with the information from the entry for the project. This tag can have up to several sub tag of type entry, mirroring the tree architecture of the project. During serialization each entry gets assigned a unique id. This ID is only valid within a single file and my change if the file is serialized again.

Following the entry tag a list of property tags is written. Each property tag has an id attribute linking it back to the corresponding entry in the beginning of the file. Each property can thereby have different sub tags and attributes depending of the entry type that get serialized.

Creating new entry types

Creating new entry types may be necessary to store new types of data in the project tree (e.g. MS data, MS annotation data) and if no existing entry type can be reused.

Create data classes

To create a new type of entry in the project hierarchy extend the Property class in package edu.uga.ccrc.simiantools.datamodel.property. DO NOT extend or modify the Entry class. The new subclass should contain all the information that need to be stored for an entry. Please not that if the entry represents a large data set (e.g. experimental raw) it is favorable to store this data in a separate file inside the project folder rather than in the property class. Since the entire project tree is loading once a project is opened this is more memory and time efficient. In such cases this property class will only contain a handle to the file with the data (e.g. relative path and file) and a class processing or displaying this entry will know how to find and read the data.

Writing the property sub class to .project.xml

Reading the property sub class from .project.xml

<extension point="edu.uga.ccrc.simiantools.entryreader">
    <reader
        class="edu.uga.ccrc.simiantools.datamodel.io.ProjectEntryReader"
        entry="edu.uga.ccrc.simiantools.entry.project">
    </reader>
</extension>
Last modified 7 years ago Last modified on 10/01/2014 11:10:21 PM

Attachments (3)

Download all attachments as: .zip