Search in sources :

Example 21 with ModelBuilderOperation

use of org.whole.lang.builders.ModelBuilderOperation in project whole by wholeplatform.

the class XsiModelTemplateTest method testXsiModelTemplate.

@Category({ KnownFailingTests.class, SlowTests.class })
@Test
public void testXsiModelTemplate() throws Exception {
    fail();
    IBindingManager bm = BindingManagerFactory.instance.createBindingManager();
    bm.wDefValue("folderLocation", new File("test/org/whole/lang/xsd/templates").getAbsolutePath());
    bm.wDefValue("packageName", "");
    XsdDeployStrategies.setDeployStrategy(bm, XsdDeployStrategies.ALL);
    String fileName = "S202SCTDIRPFRAA0001.C.xml";
    IEntity xsiModel = XsiPersistenceKit.instance().readModel(new StreamPersistenceProvider(getInputStream(fileName), null, bm));
    CommonsEntityFactory.instance.createRootFragment(xsiModel.wGetAdapter(CommonsEntityDescriptorEnum.Any));
    IEntity xmlModel = XmlSourcePersistenceKit.instance().readModel(new StreamPersistenceProvider(getInputStream(fileName), null, bm));
    CommonsEntityFactory.instance.createRootFragment(xmlModel.wGetAdapter(CommonsEntityDescriptorEnum.Any));
    ModelBuilderOperation mop = new ModelBuilderOperation();
    XmlNormalizerBuilderOperation xnbo = new XmlNormalizerBuilderOperation(mop);
    XsiModelTemplate xsiModelTemplate = new XsiModelTemplate(xsiModel);
    xsiModelTemplate.apply(xnbo);
    IEntity xmlModelFromXsiModel = mop.wGetResult();
    Assert.assertTrue(Matcher.match(xmlModelFromXsiModel, xmlModel));
}
Also used : ModelBuilderOperation(org.whole.lang.builders.ModelBuilderOperation) IEntity(org.whole.lang.model.IEntity) XmlNormalizerBuilderOperation(org.whole.lang.xml.codebase.XmlNormalizerBuilderOperation) IBindingManager(org.whole.lang.bindings.IBindingManager) StreamPersistenceProvider(org.whole.lang.codebase.StreamPersistenceProvider) File(java.io.File) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 22 with ModelBuilderOperation

use of org.whole.lang.builders.ModelBuilderOperation in project whole by wholeplatform.

the class GrammarsUtils method parse.

@SuppressWarnings("unchecked")
public static <E extends IEntity> E parse(CharSequence source, String grammarUri, EntityDescriptor<?> ed) {
    ModelBuilderOperation mop = new ModelBuilderOperation();
    parse(source, grammarUri, mop, ed);
    return (E) mop.wGetResult();
}
Also used : ModelBuilderOperation(org.whole.lang.builders.ModelBuilderOperation)

Example 23 with ModelBuilderOperation

use of org.whole.lang.builders.ModelBuilderOperation in project whole by wholeplatform.

the class RhinoTransformerVisitor method transform.

public static IEntity transform(IPersistenceProvider pp) throws Exception {
    CompilerEnvirons compilerEnvirons = CompilerEnvirons.ideEnvirons();
    compilerEnvirons.setLanguageVersion(Context.VERSION_1_8);
    Parser parser = new Parser(compilerEnvirons);
    AstRoot astRoot = parser.parse(new InputStreamReader(pp.getInputStream(), pp.getEncoding()), "http://whole.sourceforge.net/test.js", 0);
    ModelBuilderOperation mop = new ModelBuilderOperation();
    RhinoTransformerVisitor visitor = new RhinoTransformerVisitor(mop);
    astRoot.visit(visitor);
    return mop.wGetResult();
}
Also used : ModelBuilderOperation(org.whole.lang.builders.ModelBuilderOperation) InputStreamReader(java.io.InputStreamReader) CompilerEnvirons(org.mozilla.javascript.CompilerEnvirons) Parser(org.mozilla.javascript.Parser)

Example 24 with ModelBuilderOperation

use of org.whole.lang.builders.ModelBuilderOperation in project whole by wholeplatform.

the class ResourceArtifactsGeneratorTest method test2CompareArtifacts.

@Test
public void test2CompareArtifacts() {
    ArtifactsEntityFactory aef = ArtifactsEntityFactory.instance;
    File genFolder = new File("data/gen");
    ResourceTemplate resourceTemplate = new ResourceTemplate(genFolder);
    ModelBuilderOperation mop = new ModelBuilderOperation();
    resourceTemplate.apply(mop);
    IEntity artifactsRevEng = mop.wGetResult();
    IEntity artifactsSubTree = Matcher.find(aef.createFolderArtifact(aef.createName("gen"), CommonsEntityAdapterFactory.createVariable(ArtifactsEntityDescriptorEnum.Metadata, "metadata"), CommonsEntityAdapterFactory.createVariable(ArtifactsEntityDescriptorEnum.Artifacts, "artifacts")), artifacts, false);
    assertNotNull(artifactsSubTree);
    assertTrue(OrderedMatcher.match(artifactsRevEng, artifactsSubTree, comparatorsMap));
}
Also used : ModelBuilderOperation(org.whole.lang.builders.ModelBuilderOperation) ArtifactsEntityFactory(org.whole.lang.artifacts.factories.ArtifactsEntityFactory) IEntity(org.whole.lang.model.IEntity) ResourceTemplate(org.whole.lang.artifacts.templates.ResourceTemplate) File(java.io.File) Test(org.junit.Test)

Example 25 with ModelBuilderOperation

use of org.whole.lang.builders.ModelBuilderOperation in project whole by wholeplatform.

the class ResourceTemplateTest method testReadArtifacts.

@Test
public void testReadArtifacts() {
    File testfolder = new File("data/testfolder");
    ResourceTemplate template = new ResourceTemplate(testfolder);
    ModelBuilderOperation op = new ModelBuilderOperation();
    template.apply(op);
    IEntity artifacts = getFilesystemPattern();
    IEntity artifactsFromFilesystem = op.wGetResult();
    assertTrue(OrderedMatcher.match(artifacts, artifactsFromFilesystem, comparatorsMap));
}
Also used : ModelBuilderOperation(org.whole.lang.builders.ModelBuilderOperation) IEntity(org.whole.lang.model.IEntity) ResourceTemplate(org.whole.lang.artifacts.templates.ResourceTemplate) File(java.io.File) Test(org.junit.Test)

Aggregations

ModelBuilderOperation (org.whole.lang.builders.ModelBuilderOperation)41 IEntity (org.whole.lang.model.IEntity)21 Test (org.junit.Test)18 ICommonsBuilder (org.whole.lang.commons.builders.ICommonsBuilder)8 File (java.io.File)6 ModelTemplate (org.whole.lang.templates.ModelTemplate)6 XmlNormalizerBuilderOperation (org.whole.lang.xml.codebase.XmlNormalizerBuilderOperation)6 ResourceTemplate (org.whole.lang.artifacts.templates.ResourceTemplate)5 IBindingManager (org.whole.lang.bindings.IBindingManager)5 IXmlBuilder (org.whole.lang.xml.builders.IXmlBuilder)5 IArtifactsBuilder (org.whole.lang.artifacts.builders.IArtifactsBuilder)4 StreamPersistenceProvider (org.whole.lang.codebase.StreamPersistenceProvider)4 Document (org.whole.lang.xml.model.Document)4 XmlStoreProducerBuilderOperation (org.whole.lang.xml.util.XmlStoreProducerBuilderOperation)4 XmlStoreConsumerVisitor (org.whole.lang.xml.util.XmlStoreConsumerVisitor)3 Category (org.junit.experimental.categories.Category)2 WorkspaceTemplate (org.whole.lang.artifacts.templates.WorkspaceTemplate)2 IBuilderOperation (org.whole.lang.builders.IBuilderOperation)2 JavaStoreProducerBuilder (org.whole.lang.java.util.JavaStoreProducerBuilder)2 JavaStoreProducerBuilderOperation (org.whole.lang.java.util.JavaStoreProducerBuilderOperation)2