Search in sources :

Example 31 with Model

use of org.whole.lang.models.model.Model in project whole by wholeplatform.

the class XsdMappingTest method testModelsToXmlSchemaXXX.

@Test
public void testModelsToXmlSchemaXXX() throws Exception {
    IBindingManager bm = BindingManagerFactory.instance.createArguments();
    PathExpression path = new ModelToXmlSchemaQuery().create();
    Model model = (Model) ModelsTemplateManager.instance().create("Models model");
    String uri = model.getUri().getValue();
    ILanguageKit lk = ReflectionFactory.getLanguageKit(uri);
    IEntity tuple = BehaviorUtils.evaluateFirstResult(path, model, bm);
    Assert.assertNotNull(tuple);
    InterpreterOperation.interpret(tuple.wGet(1));
    ITemplateManager tm = lk.getTemplateManager();
    IEntity entity = tm.create("Editors model");
    IPersistenceProvider pp = new StringPersistenceProvider();
    XsiPersistenceKit.instance().writeModel(entity, pp);
    IEntity entity2 = XsiPersistenceKit.instance().readModel(pp);
    boolean matches = Matcher.match(entity, entity2);
    Assert.assertTrue(matches);
}
Also used : ModelToXmlSchemaQuery(org.whole.lang.xsd.codebase.ModelToXmlSchemaQuery) PathExpression(org.whole.lang.queries.model.PathExpression) StringPersistenceProvider(org.whole.lang.codebase.StringPersistenceProvider) IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) Model(org.whole.lang.models.model.Model) ITemplateManager(org.whole.lang.templates.ITemplateManager) IPersistenceProvider(org.whole.lang.codebase.IPersistenceProvider) ILanguageKit(org.whole.lang.reflect.ILanguageKit) Test(org.junit.Test)

Example 32 with Model

use of org.whole.lang.models.model.Model in project whole by wholeplatform.

the class ReflectiveAPITest method testGetters.

@Test
public void testGetters() {
    Model m = model;
    assertSame(m.getTypeRelations(), m.wGet(ModelsFeatureDescriptorEnum.typeRelations));
// TODO for each feature
}
Also used : EditorsModel(org.whole.lang.models.codebase.EditorsModel) Model(org.whole.lang.models.model.Model) Test(org.junit.Test)

Example 33 with Model

use of org.whole.lang.models.model.Model in project whole by wholeplatform.

the class Grammars2ModelsVisitor method visit.

@Override
public void visit(Grammar entity) {
    entity = normalize(entity);
    IEntityIterator<Production> lexiconIiterator = IteratorFactory.<Production>childIterator();
    lexiconIiterator.reset(entity.getLexicalStructure());
    for (Production p : lexiconIiterator) lexiconMap.put(p.getName().getValue(), p);
    LanguageDescriptor ld = (LanguageDescriptor) entity.getTargetLanguage();
    ModelsEntityFactory mf = ModelsEntityFactory.instance;
    Model model = mf.createModel(mf.createSimpleName(ld.getName().getValue()), mf.createTypeRelations(), modelDeclarations = mf.createModelDeclarations(), mf.createNamespace(ld.getNamespace().getValue()), EntityUtils.isResolver(ld.getVersion()) ? CommonsEntityAdapterFactory.createResolver(ModelsEntityDescriptorEnum.Version) : mf.createVersion(ld.getVersion().getValue()), mf.createURI(ld.getUri().getValue()));
    entity.getPhraseStructure().accept(this);
    setResult(model);
}
Also used : Production(org.whole.lang.grammars.model.Production) Model(org.whole.lang.models.model.Model) LanguageDescriptor(org.whole.lang.grammars.model.LanguageDescriptor) ModelsEntityFactory(org.whole.lang.models.factories.ModelsEntityFactory)

Example 34 with Model

use of org.whole.lang.models.model.Model in project whole by wholeplatform.

the class PojoArtifactsGeneratorVisitor method visit.

@Override
public void visit(Library library) {
    Name libraryName = library.getName();
    if (!EntityUtils.isNotResolver(libraryName))
        throw new VisitException("No library name");
    String modelFileName = DataTypeUtils.getAsPersistenceString(libraryName) + "Model";
    Model model = PojoMappingUtils.getModel(library);
    env().wDefValue("modelFileName", modelFileName);
    env().wDef("modelFileContent", model);
    IEntity ws = ModelsArtifactsTemplateManager.instance().create("ModelFileArtifact");
    Matcher.substitute(ws, env(), false);
    ArtifactsUtils.moveArtifactsIntoWorkspace(ws, env());
}
Also used : IEntity(org.whole.lang.model.IEntity) VisitException(org.whole.lang.visitors.VisitException) Model(org.whole.lang.models.model.Model) Name(org.whole.lang.pojo.model.Name)

Example 35 with Model

use of org.whole.lang.models.model.Model in project whole by wholeplatform.

the class PathExpressionsQueriesTest method testPathOfChildSteps.

@Test
public void testPathOfChildSteps() {
    Model model = new XmlModel().create();
    IEntity decl3 = model.getDeclarations().wGet(3);
    QueriesEntityFactory ef = QueriesEntityFactory.instance;
    PathExpression pe = ef.createPath(ef.createFeatureStep("declarations"), ef.createFilter(ef.createChildStep(), ef.createIndexTest(ef.createIntLiteral(3))));
    IEntity result = BehaviorUtils.evaluateFirstResult(pe, model);
    Assert.assertSame(decl3, result);
}
Also used : PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) QueriesEntityFactory(org.whole.lang.queries.factories.QueriesEntityFactory) XmlModel(org.whole.lang.models.codebase.XmlModel) Model(org.whole.lang.models.model.Model) XmlModel(org.whole.lang.models.codebase.XmlModel) Test(org.junit.Test)

Aggregations

Model (org.whole.lang.models.model.Model)62 Test (org.junit.Test)55 PathExpression (org.whole.lang.queries.model.PathExpression)43 ITemplateManager (org.whole.lang.templates.ITemplateManager)41 IEntity (org.whole.lang.model.IEntity)40 XmlModel (org.whole.lang.models.codebase.XmlModel)30 ModelsModel (org.whole.lang.models.codebase.ModelsModel)25 ModelDeclarations (org.whole.lang.models.model.ModelDeclarations)19 IBindingManager (org.whole.lang.bindings.IBindingManager)15 SimpleEntity (org.whole.lang.models.model.SimpleEntity)14 ClassDeclaration (org.whole.lang.java.model.ClassDeclaration)12 DataEntity (org.whole.lang.models.model.DataEntity)10 Feature (org.whole.lang.models.model.Feature)9 ArrayList (java.util.ArrayList)6 FieldDeclaration (org.whole.lang.java.model.FieldDeclaration)6 CompositeEntity (org.whole.lang.models.model.CompositeEntity)4 Features (org.whole.lang.models.model.Features)4 EditorsModel (org.whole.lang.models.codebase.EditorsModel)3 EnumEntity (org.whole.lang.models.model.EnumEntity)3 SimpleName (org.whole.lang.models.model.SimpleName)3