ModelParseServiceImpl implements IModelParseService<Pericope> { public RelationModel getSystemRelationModel() throws HmxException { InputStream systemModelFileInput = null; final List<Element> systemModelNodes; try { systemModelFileInput = ModelParseServiceImpl.class.getResourceAsStream("/org/hmx/scitos/hmx/core/relation-models.xml"); final Element root = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(systemModelFileInput).getDocumentElement(); systemModelNodes = DomUtil.getChildElements(root, ModelParseServiceImpl.TAG_RELMODEL); } catch (final ParserConfigurationException pcex) { throw new HmxException(Message.ERROR_UNKNOWN, pcex); } catch (final IOException ioex) { throw new HmxException(Message.ERROR_UNKNOWN, ioex); } catch (final SAXException se) { throw new HmxException(Message.ERROR_UNKNOWN, se); } finally { if (systemModelFileInput != null) { try { systemModelFileInput.close(); } catch (final IOException expected) { } } } final String userLanguage = Option.TRANSLATION.getValueAsLocale().getLanguage(); Element semanticalModelNode = null; for (final Element modelNode : systemModelNodes) { if (!modelNode.hasAttribute(ModelParseServiceImpl.ATT_LANGMODEL_LOCALE)) { semanticalModelNode = modelNode; } else if (modelNode.getAttribute(ModelParseServiceImpl.ATT_LANGMODEL_LOCALE).equals(userLanguage)) { semanticalModelNode = modelNode; break; } } if (semanticalModelNode == null) { return null; } return this.parseRelationModelFromXml(semanticalModelNode); } @Inject  ModelParseServiceImpl(); @Override List<ExportOption> getSupportedExports(); @Override Document parseXmlFromModel(final IModel<?> model, final List<?> openViewElements); Element parseXmlFromLanguageModel(final Document xml, final ISyntacticalFunctionProvider model); Element parseXmlFromRelationModel(final Document xml, final ISemanticalRelationProvider model); @Override Entry<Pericope, List<?>> parseModelFromXml(final Document xml, final File originPath); List<LanguageModel> getSystemLanguageModels(); List<LanguageModel> parseLanguageModelsFromXml(final Document xml); RelationModel getSystemRelationModel(); RelationModel parseRelationModelFromXml(final Document xml);  }
@Test public void testGetSystemRelationModel() throws HmxException { final RelationModel model = new RelationModel(); final AssociateRole sequentialNucleus = new AssociateRole("Sequential-Nucleus", true); final AssociateRole simultaneousNucleus = new AssociateRole("Simultaneous-Nucleus", true); final AssociateRole nucleus = new AssociateRole("Nucleus", true); model.add(Arrays.asList(new RelationTemplate(sequentialNucleus, sequentialNucleus, sequentialNucleus, null), new RelationTemplate( simultaneousNucleus, simultaneousNucleus, simultaneousNucleus, null), new RelationTemplate(nucleus, nucleus, nucleus, null))); final List<RelationTemplate> secondGroup = new LinkedList<>(); secondGroup.add(new RelationTemplate(new AssociateRole("Orienter", false), null, new AssociateRole("Content", true), null)); secondGroup.add(new RelationTemplate(new AssociateRole("Circumstance", false), null, nucleus, null)); secondGroup.add(new RelationTemplate(new AssociateRole("Move", false), null, new AssociateRole("Goal", true), null)); secondGroup.add(new RelationTemplate(new AssociateRole("Occasion", false), null, new AssociateRole("Outcome", true), null)); secondGroup.add(new RelationTemplate(new AssociateRole("Time", false), null, nucleus, null)); secondGroup.add(new RelationTemplate(nucleus, null, new AssociateRole("Equivalent", false), null)); secondGroup.add(new RelationTemplate(new AssociateRole("Generic", true), new AssociateRole("Specificum", false), new AssociateRole( "Specificum", false), null)); secondGroup.add(new RelationTemplate(new AssociateRole("Generic", false), null, new AssociateRole("Specificum", true), null)); secondGroup.add(new RelationTemplate(new AssociateRole("Contraction", true), null, new AssociateRole("Amplification", false), null)); secondGroup.add(new RelationTemplate(new AssociateRole("Positivum", true), null, new AssociateRole("Negativum", false), null)); secondGroup.add(new RelationTemplate(nucleus, null, new AssociateRole("Comparison", false), null)); secondGroup.add(new RelationTemplate(nucleus, null, new AssociateRole("Illustration", false), null)); secondGroup.add(new RelationTemplate(new AssociateRole("Congruence", true), null, new AssociateRole("Standard", false), null)); secondGroup.add(new RelationTemplate(nucleus, null, new AssociateRole("Manner", false), null)); secondGroup.add(new RelationTemplate(nucleus, null, new AssociateRole("Contrast", false), null)); secondGroup.add(new RelationTemplate(new AssociateRole("Reason", false), null, new AssociateRole("Consequence", true), null)); secondGroup.add(new RelationTemplate(new AssociateRole("Means", false), null, new AssociateRole("Result", true), null)); secondGroup.add(new RelationTemplate(new AssociateRole("Purpose", false), null, new AssociateRole("Means", true), null)); secondGroup.add(new RelationTemplate(new AssociateRole("Condition", false), null, new AssociateRole("Consequence", true), null)); secondGroup.add(new RelationTemplate(new AssociateRole("Concession", false), null, new AssociateRole("Contraexpectation", true), null)); secondGroup.add(new RelationTemplate(new AssociateRole("Grounds", false), null, new AssociateRole("Conclusion", true), null)); secondGroup.add(new RelationTemplate(new AssociateRole("Grounds", false), null, new AssociateRole("Exhortation", true), null)); secondGroup.add(new RelationTemplate(nucleus, null, new AssociateRole("Comment", false), null)); secondGroup.add(new RelationTemplate(nucleus, null, new AssociateRole("Parenthesis", false), null)); model.add(secondGroup); model.add(Arrays.asList(new RelationTemplate(new AssociateRole("Object", true), null, new AssociateRole("Identification", false), null), new RelationTemplate(new AssociateRole("Object", true), null, new AssociateRole("Description", false), null))); final RelationModel systemModel = ModelParseServiceImplTest.parseService.getSystemRelationModel(); Assert.assertEquals(model, systemModel); }