wiki:VersioningGritsEntryProperty

Versioning the Property object and XML element

The Property object in the core plugin is to be versioned along with the property element in the ".project.xml" file

Current Implementation

  • Each “project.xml” has entry and its corresponding property element
  • The PropertyReader in “plugin.xml” for each plugin defines property reader classes
  • Reader class reads the property element of the project xml
  • For writing the property each PropertyWriter class implements PropertyWriter

Suggested Implementation

Property element in project.xml

  • Each “project.xml” has still entry and its corresponding property element
  • Each Property element in the ".project.xml" file now has
    • id (attribute)
    • version (attribute)
    • type (attribute)
    • list of files (elements), where each file has
      • name
      • version
      • type

An example snippet of the property element in ".project.xml" file

  <property id="1" version="1.0" type="org.grits.toolbox.property.sample">
    <file name="sample35340.xml" version="1.1" type="sample"/>
    <file name="sample35315.xml" version="1.2" type="data"/>
  </property>
  <property id="2" version="1.0" type="org.grits.toolbox.property.experiment">
    <file name="exp35340.xml" version="1.0" type="sample"/>
    <file name="exp35315.xml" version="1.2" type="experiment"/>
  </property>

Property class

The abstract Property class has additional methods "String getVersionNumber()" and "List<PropertyDataFile> getFiles()" and its corresponding setters.

  • public String getVersionNumber()
    • returns the version number "1.0" onwards or null (for preversioning).
    • This method can be overwritten by classes inheriting Property class to indicate its own plugin version number or some other value
  • public List<PropertyDataFile> getFiles()
    • returns a list of PropertyDataFile or an empty list (for preversioning or other suitable properties)
    • The PropertyDataFile represents the files that stores all the information (including description of the entry)
    • The PropertyDataFile has the folllowing fields and their getters and setters
      • name - indicates the name of the file that can be found in some suitable directory (suitable directory is decided by plugins)
      • versionNumber - indicates the version number of the file which helps in reading the file
      • type - indicates the type of information stored in the file

PropertyReader class

The PropertyReader class becomes an abstract class (earlier it was an interface)

	public static void addGenericInfo(Element propertyElement, Property property)
	{
		// get version number from the propertyElement
		Attribute versionElement = propertyElement.getAttribute("version");

		if(versionElement != null)
		{
			property.setVersionNumber(versionElement.getValue());

			List<PropertyDataFile> dataFiles = new ArrayList<PropertyDataFile>();

			// retrieve files from the element
			//code for retrieving files from the element

			// add files
			property.setFiles(dataFiles);
		}
		else
		{
			property.setVersionNumber(null);
		}
	}

	public abstract Property read(Element propertyElement) throws IOException;

Class that implements the PropertyReader class

The class that implements the PropertyReader class gets the generic information from the static method of the Property class. Based on the version value it calls the appropriate class to read the content.

	public static Property read(Element propertyElement)
	{
		ExperimentProperty property = new ExperimentProperty();
		
		// fill the version and list of files
		PropertyReader.addGenericInfo(propertyElement, property);

		if(property.getVersionNumber() == null)
		{
			return ExperimentPropertyReaderV0.read(propertyElement, property);
		}
		else if(property.getVersionNumber().equals("1.0"))
		{
			return ExperimentPropertyReaderV1.read(propertyElement, property);
		}
		else if(property.getVersionNumber().equals("2.0"))
		{
			return ExperimentPropertyReaderV2.read(propertyElement, property);
		}
		else return null;
	}


Last modified 6 years ago Last modified on 09/15/2015 10:27:55 PM

Attachments (4)

Download all attachments as: .zip