Search in sources :

Example 96 with PathExpression

use of org.whole.lang.queries.model.PathExpression in project whole by wholeplatform.

the class XsdLanguageTest method testModelToXsdMapping.

@Test
public void testModelToXsdMapping() {
    try {
        IBindingManager bm = BindingManagerFactory.instance.createBindingManager();
        PathExpression path = new ModelToXmlSchemaQuery().create();
        IEntity model = XmlBuilderPersistenceKit.instance().readModel(new ClasspathPersistenceProvider("org/whole/lang/artifacts/ArtifactsModel.xwl"));
        Assert.assertNotNull(BehaviorUtils.evaluateFirstResult(path, model, bm));
        IEntity mappedXsd = bm.wGet("schema");
        IEntity xsd = loadXsd("artifacts.xsd");
        Assert.assertTrue(OrderedMatcher.match(xsd, mappedXsd, comparatorsMap));
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
}
Also used : ModelToXmlSchemaQuery(org.whole.lang.xsd.codebase.ModelToXmlSchemaQuery) PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) ClasspathPersistenceProvider(org.whole.lang.codebase.ClasspathPersistenceProvider) Test(org.junit.Test)

Example 97 with PathExpression

use of org.whole.lang.queries.model.PathExpression in project whole by wholeplatform.

the class GrammarsUIInterpreterVisitor method createGrammarBased.

public static IEntity createGrammarBased(Grammar entity, IBindingManager bm) {
    // FIXME ensure normalized: NormalizerOperation.normalize(entity);
    Grammar g = entity;
    PathExpression pathExpression = new GrammarsToGrammarBasedQuery().create();
    IEntity grammarBased = BehaviorUtils.evaluateFirstResult(pathExpression, g, bm);
    return NormalizerOperation.normalize(grammarBased);
}
Also used : PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) GrammarsToGrammarBasedQuery(org.whole.lang.grammarbased.GrammarsToGrammarBasedQuery) Grammar(org.whole.lang.grammars.model.Grammar)

Aggregations

PathExpression (org.whole.lang.queries.model.PathExpression)97 Test (org.junit.Test)94 ITemplateManager (org.whole.lang.templates.ITemplateManager)87 IEntity (org.whole.lang.model.IEntity)67 IBindingManager (org.whole.lang.bindings.IBindingManager)45 Model (org.whole.lang.models.model.Model)43 Grammar (org.whole.lang.grammars.model.Grammar)40 TestXmlGrammar (org.whole.lang.grammars.util.TestXmlGrammar)39 XmlModel (org.whole.lang.models.codebase.XmlModel)28 ModelsModel (org.whole.lang.models.codebase.ModelsModel)23 Production (org.whole.lang.grammars.model.Production)20 QueriesGrammar (org.whole.lang.grammars.codebase.QueriesGrammar)18 ModelDeclarations (org.whole.lang.models.model.ModelDeclarations)18 SimpleEntity (org.whole.lang.models.model.SimpleEntity)13 ClassDeclaration (org.whole.lang.java.model.ClassDeclaration)11 DataEntity (org.whole.lang.models.model.DataEntity)10 Feature (org.whole.lang.models.model.Feature)9 NonTerminal (org.whole.lang.grammars.model.NonTerminal)8 FieldDeclaration (org.whole.lang.java.model.FieldDeclaration)7 QueriesEntityFactory (org.whole.lang.queries.factories.QueriesEntityFactory)6