Search in sources :

Example 1 with ClasspathPersistenceProvider

use of org.whole.lang.codebase.ClasspathPersistenceProvider in project whole by wholeplatform.

the class JavaGeneratorTest method testGenerateJava.

@Test
public void testGenerateJava() throws Exception {
    IEntity artifactsModel = XmlBuilderPersistenceKit.instance().readModel(new ClasspathPersistenceProvider("org/whole/lang/artifacts/ArtifactsModel.xwl"));
    assertNotNull(artifactsModel);
    List<CompilationUnit> cuList = JavaCompilerOperation.compile(artifactsModel, BindingManagerFactory.instance.createArguments());
    assertTrue(cuList.size() > 0);
}
Also used : CompilationUnit(org.eclipse.jdt.core.dom.CompilationUnit) IEntity(org.whole.lang.model.IEntity) ClasspathPersistenceProvider(org.whole.lang.codebase.ClasspathPersistenceProvider) Test(org.junit.Test)

Example 2 with ClasspathPersistenceProvider

use of org.whole.lang.codebase.ClasspathPersistenceProvider in project whole by wholeplatform.

the class PathExpressionsQueriesTest method testKindTest.

@Test
public void testKindTest() throws Exception {
    IEntity model = XmlBuilderPersistenceKit.instance().readModel(new ClasspathPersistenceProvider("org/whole/lang/templates/codebase/TemplateManagerArtifactsTemplates.xwl"));
    QueriesEntityFactory ef = QueriesEntityFactory.instance;
    for (IEntity e : BehaviorUtils.compileAndLazyEvaluate(ef.createFilter(ef.createDescendantOrSelfStep(), ef.createKindTest(KindTestEnum.RESOLVER)), model)) Assert.assertTrue(EntityUtils.isResolver(e));
    for (IEntity e : BehaviorUtils.compileAndLazyEvaluate(ef.createFilter(ef.createDescendantOrSelfStep(), ef.createKindTest(KindTestEnum.DATA)), model)) Assert.assertTrue(EntityUtils.isData(e));
    for (IEntity e : BehaviorUtils.compileAndLazyEvaluate(ef.createFilter(ef.createDescendantOrSelfStep(), ef.createKindTest(KindTestEnum.FRAGMENT)), model)) Assert.assertTrue(EntityUtils.isFragment(e));
}
Also used : IEntity(org.whole.lang.model.IEntity) QueriesEntityFactory(org.whole.lang.queries.factories.QueriesEntityFactory) ClasspathPersistenceProvider(org.whole.lang.codebase.ClasspathPersistenceProvider) Test(org.junit.Test)

Example 3 with ClasspathPersistenceProvider

use of org.whole.lang.codebase.ClasspathPersistenceProvider in project whole by wholeplatform.

the class JSONPersistencesTest method testJSONLDPersistence.

@Test
public void testJSONLDPersistence() throws Exception {
    StringPersistenceProvider pp = new StringPersistenceProvider();
    for (String modelPath : models) {
        IEntity sourceModel = XmlBuilderPersistenceKit.instance().readModel(new ClasspathPersistenceProvider(modelPath));
        pp.delete();
        JSONLDPersistenceKit.instance().writeModel(sourceModel, pp);
        IEntity targetModel = JSONLDPersistenceKit.instance().readModel(pp);
        assertTrue(Matcher.forceMatch(sourceModel, targetModel));
    }
}
Also used : StringPersistenceProvider(org.whole.lang.codebase.StringPersistenceProvider) IEntity(org.whole.lang.model.IEntity) ClasspathPersistenceProvider(org.whole.lang.codebase.ClasspathPersistenceProvider) Test(org.junit.Test)

Example 4 with ClasspathPersistenceProvider

use of org.whole.lang.codebase.ClasspathPersistenceProvider in project whole by wholeplatform.

the class IteratorFactoryTest method testTopDownIterator.

@Test
public void testTopDownIterator() throws Exception {
    Grammar g = new TestXmlGrammar().create();
    final Productions productions = g.getPhraseStructure();
    final IEntityIterator<IEntity> ci = IteratorFactory.<IEntity>descendantOrSelfIterator();
    ci.reset(productions);
    IVisitor v = GenericTraversalFactory.instance.topDown(new GenericIdentityVisitor() {

        public void visit(IEntity entity) {
            if (ci.hasNext())
                assertSame(entity, ci.next());
            else
                fail();
        }
    }, false);
    v.visit(productions);
    final IEntityIterator<IEntity> ci2 = IteratorFactory.<IEntity>descendantOrSelfScannerIterator();
    ci2.reset(productions);
    v = GenericTraversalFactory.instance.topDown(new GenericIdentityVisitor() {

        public void visit(IEntity entity) {
            if (EntityUtils.isResolver(entity))
                return;
            if (ci2.hasNext())
                assertSame(entity, ci2.next());
            else
                fail();
        }
    }, false);
    v.visit(productions);
    final IEntityIterator<IEntity> ci3 = IteratorFactory.<IEntity>descendantOrSelfMatcherIterator().withPattern(GrammarsEntityDescriptorEnum.Production);
    ci3.reset(productions);
    v = GenericTraversalFactory.instance.topDown(new GenericIdentityVisitor() {

        public void visit(IEntity entity) {
            if (!Matcher.match(GrammarsEntityDescriptorEnum.Production, entity))
                return;
            if (ci3.hasNext())
                assertSame(entity, ci3.next());
            else
                fail();
        }
    }, false);
    v.visit(productions);
    IEntity artifactsModel = XmlBuilderPersistenceKit.instance().readModel(new ClasspathPersistenceProvider("org/whole/lang/artifacts/ArtifactsModel.xwl"));
    Set<Type> typeSet = new HashSet<Type>();
    IEntityIterator<Type> ci4 = IteratorFactory.<Type>descendantOrSelfMatcherIterator().withPattern(ModelsEntityFactory.instance.createSimpleName("Atifacts"));
    ci4.reset(artifactsModel);
    while (ci4.hasNext()) assertTrue(typeSet.add(ci4.next()));
}
Also used : Productions(org.whole.lang.grammars.model.Productions) Type(org.whole.lang.models.model.Type) IEntity(org.whole.lang.model.IEntity) IVisitor(org.whole.lang.visitors.IVisitor) TestXmlGrammar(org.whole.lang.grammars.util.TestXmlGrammar) ClasspathPersistenceProvider(org.whole.lang.codebase.ClasspathPersistenceProvider) TestXmlGrammar(org.whole.lang.grammars.util.TestXmlGrammar) Grammar(org.whole.lang.grammars.model.Grammar) GenericIdentityVisitor(org.whole.lang.visitors.GenericIdentityVisitor) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 5 with ClasspathPersistenceProvider

use of org.whole.lang.codebase.ClasspathPersistenceProvider in project whole by wholeplatform.

the class DTAUSDeployer method deploy.

public void deploy(ReflectionFactory platform) {
    try {
        IBindingManager bm = BindingManagerFactory.instance.createArguments();
        IEntity model = XsdPersistenceKit.instance().readModel(new ClasspathPersistenceProvider("org/whole/examples/dataintegration/xsd/pain.001.001.02.xsd", bm));
        InterpreterOperation.interpret(model, bm);
        InterpreterOperation.interpret(new DTAUSGrammar().create());
        model = XmlBuilderPersistenceKit.instance().readModel(new ClasspathPersistenceProvider("org/whole/examples/dataintegration/xsd/DTAUSActions.xwl"));
        InterpreterOperation.interpret(model);
    } catch (Exception e) {
        E4CompatibilityPlugin.log(e);
    }
}
Also used : IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) ClasspathPersistenceProvider(org.whole.lang.codebase.ClasspathPersistenceProvider)

Aggregations

ClasspathPersistenceProvider (org.whole.lang.codebase.ClasspathPersistenceProvider)15 IEntity (org.whole.lang.model.IEntity)12 Test (org.junit.Test)11 IBindingManager (org.whole.lang.bindings.IBindingManager)4 QueriesEntityFactory (org.whole.lang.queries.factories.QueriesEntityFactory)2 PathExpression (org.whole.lang.queries.model.PathExpression)2 IVisitor (org.whole.lang.visitors.IVisitor)2 ModelToXmlSchemaQuery (org.whole.lang.xsd.codebase.ModelToXmlSchemaQuery)2 File (java.io.File)1 HashSet (java.util.HashSet)1 CoreException (org.eclipse.core.runtime.CoreException)1 Execute (org.eclipse.e4.core.di.annotations.Execute)1 MUIElement (org.eclipse.e4.ui.model.application.ui.MUIElement)1 MPerspective (org.eclipse.e4.ui.model.application.ui.advanced.MPerspective)1 MPerspectiveStack (org.eclipse.e4.ui.model.application.ui.advanced.MPerspectiveStack)1 MPart (org.eclipse.e4.ui.model.application.ui.basic.MPart)1 MPartSashContainer (org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainer)1 MPartStack (org.eclipse.e4.ui.model.application.ui.basic.MPartStack)1 MTrimBar (org.eclipse.e4.ui.model.application.ui.basic.MTrimBar)1 MTrimmedWindow (org.eclipse.e4.ui.model.application.ui.basic.MTrimmedWindow)1