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);
}
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
}
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);
}
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());
}
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);
}
Aggregations