2.7. Explanation of already implemented and used Features

2.7.1. FileTreeWalkerFeature (short: FTW)

Figure 2.4. Model of the FileTreeWalkerFeature

Model of the FileTreeWalkerFeature

The FTW (see Figure 2.4, “Model of the FileTreeWalkerFeature” ) is a Pre- and a PostFeature, so it can run before and after the generation. It is useful to prepare other features that implement the FileTreeObserver (short: FTO) interface. FTOs can be registered on an FTW as observers. An FTW walks through the file tree and calls different update methods (depending on the status) on its observers. Observers can be added in the workflow file as follows:

<preFeature class="org.genesez.platforms.common.workflow.feature.FileTreeWalkerFeature">
	<observer class="org.genesez.platforms.common.workflow.feature.aObserver" />
</preFeature>	
			

Note

After one file tree walk all observers will be unregistered.

For implementation details see ??? .

2.7.2. DeletionFeature

Figure 2.5. Model of the DeletionFeature

Model of the DeletionFeature

The DeletionFeature manages the deletion of old files or empty packages, also in different revision systems (see Section 2.7.2.1, “Support of different revision control systems (RCS)” for more information about revision systems). It is divided into two separate features the File- and FolderDeletionFeature to allow different configurations. See Figure 2.5, “Model of the DeletionFeature”

It provides the two subfeatures with some basic functionality see ??? for implementation details.

2.7.2.1. Support of different revision control systems (RCS)

Figure 2.6. Model of the implemented structure for revision control systems

Model of the implemented structure for revision control systems

To prevent missing files in repositories a structure that allows deletion of files in different RCS was needed, therefore we implemented the structure seen in Figure 2.6, “Model of the implemented structure for revision control systems ”

Some short description of used methods is given below:

getMetadataFolderName

gets the name of the directory where the repository dependent metadata is stored (e. g. for Subversion these are ".svn" folders)

This is used to check what revision control system(s) is/are used.

setRepositoryRoot

Sets the place where the metadata folder was found. For some revision systems (e. g. Git) this must be known to do deletion or other stuff.

toString

This returns just the String representation of the RCS for the Log.

markForDelete

This is the main method, the given file will be marked for deletion in the concrete repository. Therefore the repositoryRoot maybe needed.

Note

The file is only marked for deletion in the repository and will not be deleted from the file system during this operation.

Currently there are implementations for following RCS:

- Subversion , metadataFolderName=.svn
- Git , metadataFolderName=.git, needs repositoryRoot
- also all RCS where its no problem to delete the metadataFolders (like CVS)

2.7.2.2. FileDeletionFeature

The FileDeletionFeature is used to delete old files. It is a PostFeature and an FTO and needs to be an observer of an FTW in the PRE section. Because as observer it checks all files for their last modification dates. As feature it looks after the generation if the last modification dates have changed. The files were the dates didn't change will be deleted. For more information and further configuration see FileDeletionFeature

Caution

Use this feature ONLY with the right configuration order to prevent loss of information:

1st: Register an FTW as a PreFeature
2nd: Register the FileDeletionFeature as an observer to the FTW
before 1st or 3rd: Register the same FileDeletionFeature as PostFeature

In the workflow file this looks like this:

	
<preFeature class="org.genesez.platforms.common.workflow.feature.FileTreeWalkerFeature">
	<observer class="org.genesez.platforms.common.workflow.feature.FileDeletionFeature" id="fileDeletion" />
</preFeature>

<postFeature idRef="fileDeletion" />
					

For implementation details see ??? .

2.7.2.3. FolderDeletionFeature

The FolderDeletionFeature is used to delete empty folders. It is a PostFeature and an FTO and needs to be an observer of an FTW in the POST section. While its an observer it checks which folders are empty and as feature it deletes the empty folders if possible. For more information and further configuration see FolderDeletionFeature

The configuration order of this feature is not so vital but the feature makes only sense if configured right. Therefore following steps make sense:

1st: Register an FTW as a PostFeature
2nd: Register the FolderDeletionFeature as an observer to the FTW
3rd: Register the same FolderDeletionFeature as PostFeature

In the workflow file this looks like this:

<postFeature class="org.genesez.platforms.common.workflow.feature.FileTreeWalkerFeature">
	<observer class="org.genesez.platforms.common.workflow.feature.FolderDeletionFeature" id="folderDeletion" />
</postFeature>

<postFeature idRef="folderDeletion" />
					

For implementation details see ??? .

2.7.3. ImportBeautifier

Figure 2.7. Model of the ImportBeautifier

Model of the ImportBeautifier

The ImportBeautifier (see Figure 2.7, “Model of the ImportBeautifier” ) is used to carry over own imports from the old files to the new generated files and to remove double imports. It is a PostProcessor and an FTO and needs to be an observer of an FTW in the PRE section. While its an observer it checks the File-ID for each file and stores them, together with the imports in that file, in a map. During postprocessing of a file, the File-ID will be searched and the corresponding imports will be placed into the next free space of the file. After that double imports will be removed.

The ImportBeautifier needs a little extra configuration to work properly, so you must give them the used file extensions and the used import strings or a import regular expression, for more information see ImportBeautifier.

The configuration order is not vital, but it will only work if its configured right. Therefore following steps make sense:

1st: Register FTW as a PreFeature
2nd: Register ImportBeautifier as observer to the FTW
3rd: set file extensions and import strings or import regular expression.
before 1st or 4th: Register same ImportBeautifier as postprocessor.

in the workflow file this looks like this:

<preFeature class="org.genesez.platforms.common.workflow.feature.FileTreeWalkerFeature">
	<observer class="org.genesez.platforms.common.m2t.ImportBeautifier" id="import" />
		<fileExtensions value=".extension1, .extension2, ..." />
		<importStrings value="importString1, importString2, ..." />
</preFeature>

<postProcessor idRef="import" />
			

For implementation details see ??? .