CoastalHacking / semiotics-main

Semiotics models and stand-alone product / UI
Apache License 2.0
0 stars 0 forks source link

Generalize the creating of Adding Items #37

Closed jpasski closed 8 years ago

jpasski commented 8 years ago

DynamicMenuAssessmentHandler and AddAssessmentHandler are specialized for assessments. Issue #21 talks about creating snippets from a context menu. This pattern is going to be repeated a lot: entry points, sinks, crypto, authentication, etc.

Instead of repeating the same thing here, create a conversion service. A basic API would be something like so:

package ... .extension.convert;
interface ModelConverter {
  // return null if none
  <D> D convert(Class<?> source, Object sourceObject, Class<D> destination);
  // return empty map if none
  Map<String, ?> getConvertibles(Class<?> source);
  boolean isConvertible(Class<?> source);
}

Consumers of the API bind 0..many ModelConverter services, calling them in parallel or sequential. It's up to the consumer to deal with multiple returned values for the same source object.

Right now everything I'll be working currently will be IAdaptable, so I could specialize a provider for this case. If so, it seems an approach is to register an IAdapterFactory that can handle the types. And it seems the IAdapterManager should be available via an OSGi service. So I could add factories for each type. This might help with identifying a better interface on the models too :) The provider should handle the ECP projects along with the EObjects.

jpasski commented 8 years ago

Fixed in issue #21, closing this issue.