[78] | 1 | package com.framsticks.examples; |
---|
| 2 | |
---|
| 3 | import com.framsticks.core.Instance; |
---|
| 4 | import com.framsticks.core.Node; |
---|
| 5 | import com.framsticks.core.Parameters; |
---|
| 6 | import com.framsticks.core.Path; |
---|
| 7 | import com.framsticks.model.*; |
---|
| 8 | import com.framsticks.model.Package; |
---|
| 9 | import com.framsticks.params.*; |
---|
| 10 | import com.framsticks.params.types.CompositeParam; |
---|
| 11 | import com.framsticks.parsers.F0Parser; |
---|
| 12 | import com.framsticks.parsers.Schema; |
---|
| 13 | import org.apache.log4j.Logger; |
---|
| 14 | |
---|
| 15 | import java.util.List; |
---|
| 16 | |
---|
| 17 | /** |
---|
| 18 | * Author: Piotr Śniegowski |
---|
| 19 | */ |
---|
| 20 | public class GenotypeBrowser extends Instance { |
---|
| 21 | |
---|
| 22 | private static final Logger LOGGER = Logger.getLogger(Instance.class.getName()); |
---|
| 23 | protected Schema schema; |
---|
| 24 | |
---|
| 25 | |
---|
| 26 | public GenotypeBrowser(Parameters parameters) { |
---|
| 27 | super(parameters); |
---|
| 28 | LOGGER.info("model builder created"); |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | @Override |
---|
| 32 | protected void configure() throws Exception { |
---|
| 33 | super.configure(); |
---|
| 34 | schema = new Schema(Schema.getDefaultDefinitionAsStream()); |
---|
| 35 | this.registry = schema.getRegistry(); |
---|
| 36 | Package.register(this.getRegistry()); |
---|
| 37 | |
---|
| 38 | registry.putInfoIntoCache(new FramsClass("ModelBuilderRoot", "ModelBuilderRoot", null) |
---|
[79] | 39 | .append(new ParamBuilder().setType("o Model").setId("model").setName("model").build()) |
---|
[78] | 40 | ); |
---|
| 41 | root = new Node((CompositeParam)new ParamBuilder().setType("o ModelBuilderRoot").setId(name).setName("Instance").build(), PropertiesAccess.createPropertiesMap()); |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | @Override |
---|
| 45 | protected void run() { |
---|
| 46 | assert isActive(); |
---|
| 47 | |
---|
| 48 | try { |
---|
| 49 | List<AccessInterface> accesses = new F0Parser(schema, GenotypeBrowser.class.getResourceAsStream("/examples/f0_example.txt")).parse(); |
---|
| 50 | List<Object> objects = Util.stripAccessInterface(accesses); |
---|
[79] | 51 | Model model = Model.build(objects); |
---|
[78] | 52 | |
---|
| 53 | AccessInterface rootAccess = bindAccess(new Path(this, "/")); |
---|
| 54 | |
---|
[79] | 55 | rootAccess.set("model", model); |
---|
[78] | 56 | |
---|
| 57 | } catch (Exception e) { |
---|
| 58 | LOGGER.error("exception caught: " + e); |
---|
| 59 | } |
---|
| 60 | //done(); |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | } |
---|