Search in sources :

Example 1 with Library

use of org.whole.lang.pojo.model.Library in project whole by wholeplatform.

the class PojoMappingUtils method getLibrary.

public static Library getLibrary(Misc compilationUnits, IBindingManager bindings) {
    PathExpression javaModelToPojoModel = new JavaModelToPojoModelQuery().create();
    Library library = BehaviorUtils.<Library>evaluateFirstResult(javaModelToPojoModel, compilationUnits, bindings);
    Matcher.removeVars(library, true);
    return library;
}
Also used : JavaModelToPojoModelQuery(org.whole.lang.pojo.templates.JavaModelToPojoModelQuery) PathExpression(org.whole.lang.queries.model.PathExpression) Library(org.whole.lang.pojo.model.Library)

Example 2 with Library

use of org.whole.lang.pojo.model.Library in project whole by wholeplatform.

the class PojoMappingUtils method getModel.

public static Model getModel(Library library) {
    IBindingManager bindings = BindingManagerFactory.instance.createBindingManager();
    PathExpression pojoModelToModels = new PojoModelToModelsQuery().create();
    Library normalizedLibrary = NormalizerOperation.normalize(EntityUtils.clone(library));
    Model model = BehaviorUtils.<Model>evaluateFirstResult(pojoModelToModels, normalizedLibrary, bindings);
    Matcher.removeVars(model, true);
    return model;
}
Also used : PathExpression(org.whole.lang.queries.model.PathExpression) PojoModelToModelsQuery(org.whole.lang.pojo.templates.PojoModelToModelsQuery) IBindingManager(org.whole.lang.bindings.IBindingManager) Model(org.whole.lang.models.model.Model) Library(org.whole.lang.pojo.model.Library)

Example 3 with Library

use of org.whole.lang.pojo.model.Library in project whole by wholeplatform.

the class PojoUtilsTest method testTranslateFromPojoClasses.

// FIXME
@Category(KnownFailingTests.class)
@Test
public void testTranslateFromPojoClasses() {
    Object simplePojo = createPojo();
    Misc compilationUnits = getCompilationUnits(CLASSES);
    Library library = PojoMappingUtils.getLibrary(compilationUnits, "SimplePojo");
    IEntity mappedModel = PojoMappingUtils.getModel(library);
    InterpreterOperation.interpret(mappedModel);
    Library normalizedLibrary = NormalizerOperation.normalize(EntityUtils.clone(library));
    IEntity simplePojoModel = PojoUtils.create(simplePojo, normalizedLibrary);
    Object simplePojoObject = PojoUtils.create(simplePojoModel, normalizedLibrary);
    Assert.assertEquals(simplePojoObject, simplePojo);
}
Also used : IEntity(org.whole.lang.model.IEntity) Misc(org.whole.lang.misc.model.Misc) Library(org.whole.lang.pojo.model.Library) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 4 with Library

use of org.whole.lang.pojo.model.Library in project whole by wholeplatform.

the class PojoMappingUtils method getLibrary.

public static Library getLibrary(Misc compilationUnits, String libraryName, String libraryLanguageURI, boolean generatePropertyTemplates) {
    IBindingManager bindings = BindingManagerFactory.instance.createBindingManager();
    bindings.wDefValue("libraryName", libraryName);
    bindings.wDefValue("libraryLanguageURI", libraryLanguageURI);
    if (generatePropertyTemplates)
        bindings.wDefValue("generatePropertyTemplates", true);
    Library library = getLibrary(compilationUnits, bindings);
    return library;
}
Also used : IBindingManager(org.whole.lang.bindings.IBindingManager) Library(org.whole.lang.pojo.model.Library)

Example 5 with Library

use of org.whole.lang.pojo.model.Library in project whole by wholeplatform.

the class LibraryPart method getModelSpecificChildren.

protected List<IEntity> getModelSpecificChildren() {
    Library library = getModelEntity();
    List<IEntity> list = new ArrayList<IEntity>(4);
    list.add(library.getAnnotations());
    list.add(library.getName());
    list.add(library.getLanguageURI());
    list.add(library.getDeclarations());
    return list;
}
Also used : IEntity(org.whole.lang.model.IEntity) ArrayList(java.util.ArrayList) Library(org.whole.lang.pojo.model.Library)

Aggregations

Library (org.whole.lang.pojo.model.Library)5 IBindingManager (org.whole.lang.bindings.IBindingManager)2 IEntity (org.whole.lang.model.IEntity)2 PathExpression (org.whole.lang.queries.model.PathExpression)2 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 Category (org.junit.experimental.categories.Category)1 Misc (org.whole.lang.misc.model.Misc)1 Model (org.whole.lang.models.model.Model)1 JavaModelToPojoModelQuery (org.whole.lang.pojo.templates.JavaModelToPojoModelQuery)1 PojoModelToModelsQuery (org.whole.lang.pojo.templates.PojoModelToModelsQuery)1