wiki:CORE_MVC_BASE_R2

Version 4 (modified by mitex, 16 years ago) (diff)

--

Error: Macro BackLinksMenu(None) failed
compressed data is corrupt

Error: Macro TicketQuery(summary=CORE_MVC_BASE_R2, format=table, col=summary|owner|status|type|component|priority|effort|importance, rows=description|analysis_owners|analysis_reviewers|analysis_score|design_owners|design_reviewers|design_score|implementation_owners|implementation_reviewers|implementation_score|test_owners|test_reviewers|test_score|) failed
current transaction is aborted, commands ignored until end of transaction block

Analysis

Overview

This task should provide the ability to have priority among simple operations.

Task requirements

  • The operations must have a sort order key(equivalent to their priority).
  • The sortKey of an operation should be accessible through the class org.sophie2.core.mvc.SimpleOperation.
  • The extension point will sort the registered extensions according to this key.

Task result

The result of this task should be:

  • source code

Implementation idea

  • Create an annotation which would mark that an existing operation has a sort order key.
  • Add functionality to get the sortKey of an operation in the class org.sophie2.core.mvc.SimpleOperation.
    • Using Reflection get the sort order key through the annotation if it is available for this operation
    • otherwise assume that the sortKey is an empty string.
    • This makes certain that all operations which have not provided a sortKey will have equal prioryty when they are rigisterred as extensions.
  • Assure that the extension point will sort the registered extensions according to the sort order key.
    • Override the method getSorter() from the class SophieExtensionPoint<T> in org.sophie2.core.mvc.CoreMvcModule, to provide a proper Comparator which would compare the operations acording to their sorKey if such is available.

How to demo

Design

  • A new annotation will be introduced.
    • Using this annotation an operation will define its sort order key and this assures that different operations which have similar event filters can have different priority.
    • The annotation will have String sortKey();
  • The interface org.sophie2.core.mvc.OperationR3 will be modified.
    • A method getSortKey() will be added.
      • It will return the sort order key of the current OperationR3 object.
      • If the operation hasn't defined sortKey through the Sortable annotation the method will return an empty string, otherwise the method should return the corresponding sort order key.
      • This is achieved in the following manner - we obtain the operationDef object - corresponding to the particular operation, then we get from the enumeration the appropriate enum field representing the current SimpleOperation and finally we obtain its sortkey if such is available.
  • The class org.sophie2.core.mvc.CoreMvcModule will be modified.
    • In the existing public static class OperationPoint which extends SophieExtensionPoint<OperationR3> we will overload the method getSorter() inherited from SophieExtensionPoint<T> located in org.sophie2.core.modularity.
    • The method should return the result of compareTo applied to the keys.
    • Follow this rule:
      • Smaller sort key means higher priority.
      • Exception case: empty sort key has lower priority than any other key.

Implementation

  • Done according to design.

Testing

Comments