You get a model through an implementation of the org.tm4j.panckoucke.model.ModelProvider-interface. At the time of writing, this Interface defines two getModel() -methods, which differ in how you specify the abstractor to use:
public AModel getModel(AMMember member, String abstractorClassname, AbstractionContext options) throws UnsupportedAMMemberClassException, AbstractorInstantiationException;
public AModel getModel(AMMember member, Abstractor abstractor, AbstractionContext options) throws UnsupportedAMMemberClassException, AbstractorInstantiationException;
You pass the method an instance of AMMember that you did receive from a call to a StoreManager-Method or from a model. Be careful not to pass an instance of an arbitrary AMMember-Implementation, since this may lead to an UnsupportedAMMemberClassException.
If you choose to supply the abstractor to use by its classname, you pass it as the abstractorClassName-parameter. The name must be full qualified and must refer to a class that implements the InstantiableAbstractor-Interface and supports the additional contract which is described informally in the java-doc of that interface (no-arguments-constructor...).
Alternatively you may pass an existing abstractor instance to the getModel()-method. A proper initialized instance can be received via the PanckouckeContext.
The value of the options-param is passed through to the abstractor. It is always safe to pass an empty AbstractionContext-Instance. Please refer to the descriptons of the available abstractors for a discussion how the properties of the abstraction context influences the model generation.
try{ //Assuming you have an AMMember and the connection to the model-provider. String abstractorClassname = "org.tm4j.panckoucke.impl.abstraction.compact.CompactAbstractor"; AModel model = modelProvider.getModel(member, abstractorClassname,null); renderer.renderModel(model); } catch(UnsupportedOperationException ex){ // Abstractor was not able to serve this request // ok } catch(AbstractorInstantiationException ex){ // Modelprovider could not initialize Abstractor ex.printStackTrace(); } catch(UnsupportedAMMemberClassException ex){ // Modelprovider does not know this AMMemberImplementation ex.printStackTrace(); }
About the exceptions
The Abstractor was not able to satisfy the request. Since it is not possible to reach the Abstractors method supportsAbstraction(..) via the Panckoucke-API, this Exception is the only way to check, if an Abstractor is able to serve your request
The ModelProvider failed to create a new Instance of the given class. The Instantiation may fail due to a variety of reasons. See a nested Exception for more detailed information about the cause of the failure.
The AMMember passed in is an instance of a concrete implementation, which does not fit with the needs of this Modelprovider-Implementation. This is the case, when the object the AMMember represents, is not of the expected type. For example, the ModelproviderImpl, which is contained in the Panckoukce-Pkg, expects a TopicMapObject as the represented Object of an AMMember. On the other hand, a ModelProvider which lives on a client and is connected via Kamal to tm4j would expect that its AMMember represents some sort of serialized id.