In previous steps, you declared a new model connector to MDWorkbench. Now you have to provide the implementation of this connector using Java code.
To define the connector implementation:
package com.sodius.mdw.example.library; import com.sodius.mdw.core.CoreException; import com.sodius.mdw.core.model.Model; import com.sodius.mdw.core.model.io.ConnectorContext; import com.sodius.mdw.core.model.io.ModelReader; import com.sodius.mdw.metamodel.library.Book; import com.sodius.mdw.metamodel.library.Writer; public class MyReader implements ModelReader { public void read(String uri, Model model, ConnectorContext context) throws CoreException { // create a Writer Writer writer = (Writer) model.create("Writer"); writer.setName("William Shakespeare"); // create a Book Book book = (Book) model.create("Book"); book.setTitle("King Lear"); book.setAuthor(writer); } }
Refer to the Javadoc of ModelReader
or ModelWriter
for details on the contents of a model connector.