use of org.whole.lang.builders.ModelBuilderOperation in project whole by wholeplatform.
the class XsiModelTemplateTest method testXsdModelTemplate.
@Test
public void testXsdModelTemplate() throws Exception {
String pacs002FileName = "pacs.002.001.02S2.xsd";
IEntity xsdPacs002 = loadXMLSchema(pacs002FileName);
CommonsEntityFactory.instance.createRootFragment(xsdPacs002.wGetAdapter(CommonsEntityDescriptorEnum.Any));
IEntity xmlPacs002 = XmlSourcePersistenceKit.instance().readModel(new StreamPersistenceProvider(getInputStream(pacs002FileName)));
CommonsEntityFactory.instance.createRootFragment(xmlPacs002.wGetAdapter(CommonsEntityDescriptorEnum.Any));
ModelBuilderOperation mop = new ModelBuilderOperation();
XmlNormalizerBuilderOperation xnbo = new XmlNormalizerBuilderOperation(mop);
XsdModelTemplate xsdModelTemplate = new XsdModelTemplate(xsdPacs002);
xsdModelTemplate.apply(xnbo);
IEntity xmlModelFromXsdPacs002 = mop.wGetResult();
Assert.assertTrue(OrderedMatcher.match(xmlModelFromXsdPacs002, xmlPacs002, comparatorsMap));
String credTrfFileName = "SCTCcfBlkCredTrf.xsd";
IEntity xsdCredTrf = loadXMLSchema(credTrfFileName);
CommonsEntityFactory.instance.createRootFragment(xsdCredTrf.wGetAdapter(CommonsEntityDescriptorEnum.Any));
IEntity xmlCredTrf = XmlSourcePersistenceKit.instance().readModel(new StreamPersistenceProvider(getInputStream(credTrfFileName)));
CommonsEntityFactory.instance.createRootFragment(xmlCredTrf.wGetAdapter(CommonsEntityDescriptorEnum.Any));
mop = new ModelBuilderOperation();
xnbo = new XmlNormalizerBuilderOperation(mop);
xsdModelTemplate = new XsdModelTemplate(xsdCredTrf);
xsdModelTemplate.apply(xnbo);
IEntity xmlModelFromXsdCredTrf = mop.wGetResult();
Assert.assertTrue(OrderedMatcher.match(xmlModelFromXsdCredTrf, xmlCredTrf, comparatorsMap));
}
use of org.whole.lang.builders.ModelBuilderOperation in project whole by wholeplatform.
the class AttributesMatcherFactory method getDefaultNsDeclPattern.
private static IEntity getDefaultNsDeclPattern() {
if (defaultNsDeclPattern == null) {
ModelBuilderOperation mop = new ModelBuilderOperation();
IXmlBuilder xb = (IXmlBuilder) mop.wGetBuilder(XmlLanguageKit.URI);
ICommonsBuilder cb = (ICommonsBuilder) mop.wGetBuilder(CommonsLanguageKit.URI);
xb.Attribute_();
xb.Name("xmlns");
cb.Variable_();
cb.VarType(XmlEntityDescriptorEnum.Value);
cb.VarName("uri");
cb.Quantifier(QuantifierEnum.MANDATORY);
cb._Variable();
xb._Attribute();
defaultNsDeclPattern = mop.wGetResult();
}
return defaultNsDeclPattern;
}
use of org.whole.lang.builders.ModelBuilderOperation in project whole by wholeplatform.
the class AttributesMatcherFactory method getRefAttrPattern.
private static IEntity getRefAttrPattern() {
if (refAttrPattern == null) {
ModelBuilderOperation mop = new ModelBuilderOperation();
IXmlBuilder xb = (IXmlBuilder) mop.wGetBuilder(XmlLanguageKit.URI);
ICommonsBuilder cb = (ICommonsBuilder) mop.wGetBuilder(CommonsLanguageKit.URI);
xb.Attribute_();
xb.Name("ref");
cb.Variable_();
cb.VarType(XmlEntityDescriptorEnum.Value);
cb.VarName("value");
cb.Quantifier(QuantifierEnum.MANDATORY);
cb._Variable();
xb._Attribute();
refAttrPattern = mop.wGetResult();
}
return refAttrPattern;
}
use of org.whole.lang.builders.ModelBuilderOperation in project whole by wholeplatform.
the class XmlBuilderPersistenceKit method doReadModel.
protected IEntity doReadModel(IPersistenceProvider pp) throws Exception {
IEntity xmlModel = SaxConsumerHandler.parse(pp.getInputStream(), pp.getEncoding());
ModelBuilderOperation op = new ModelBuilderOperation().withBindings(pp.getBindings());
new XmlStoreConsumerVisitor(op).visit(xmlModel);
return ReflectionFactory.makeRootEntity(op.wGetResult());
}
use of org.whole.lang.builders.ModelBuilderOperation in project whole by wholeplatform.
the class WorkspaceResourceOperations method toArtifactsModel.
public IEntity toArtifactsModel(IResource resource) {
ModelBuilderOperation mbo = new ModelBuilderOperation();
WorkspaceTemplate resourceTemplate = new WorkspaceTemplate(resource, false);
resourceTemplate.apply(mbo);
return mbo.wGetResult();
}
Aggregations