use of org.whole.lang.builders.ModelBuilderOperation in project whole by wholeplatform.
the class ResourceArtifactsOperations method toArtifactsModel.
public IEntity toArtifactsModel(File resource) {
ModelBuilderOperation mbo = new ModelBuilderOperation();
ResourceTemplate resourceTemplate = new ResourceTemplate(resource);
resourceTemplate.apply(mbo);
return mbo.wGetResult();
}
use of org.whole.lang.builders.ModelBuilderOperation in project whole by wholeplatform.
the class JavaBuilderPersistenceKit method doWriteModel.
protected void doWriteModel(IEntity model, IPersistenceProvider pp) throws Exception {
IBindingManager bm = pp.getBindings();
if (bm.wIsSet("file")) {
Object file = bm.wGetValue("file");
if (file instanceof File)
bm.wDefValue("className", StringUtils.stripFileExtension(((File) file).getName()));
}
if (// TODO test was !bm.wIsSet("className") &&
bm.wIsSet("fileName"))
bm.wDefValue("className", bm.wStringValue("fileName"));
IEntity packageNameEntity = bm.wGet("packageName");
String packageName = packageNameEntity != null ? packageNameEntity.wStringValue() : null;
IEntity classNameEntity = bm.wGet("className");
String className = classNameEntity != null ? bm.wStringValue("className") : "AnonymousClass";
ModelBuilderOperation op = new ModelBuilderOperation();
JavaStoreProducerBuilderOperation javaOp = new JavaStoreProducerBuilderOperation(op);
((JavaStoreProducerBuilder) javaOp.wGetBuilder()).buildStartCompilationUnit(packageName, className, model.wGetEntityDescriptor().getEntityType().getName());
new ModelTemplate(model).apply(javaOp);
((JavaStoreProducerBuilder) javaOp.wGetBuilder()).buildEndCompilationUnit();
IEntity javaModel = op.wGetResult();
PrettyPrinterOperation.prettyPrint(javaModel, pp.getOutputStream(), pp.getEncoding());
}
use of org.whole.lang.builders.ModelBuilderOperation in project whole by wholeplatform.
the class AbstractTemplateFactory method create.
@SuppressWarnings("unchecked")
public E create() {
ModelBuilderOperation op = new ModelBuilderOperation();
apply(op);
return (E) ReflectionFactory.makeRootEntity(op.wGetResult());
}
use of org.whole.lang.builders.ModelBuilderOperation in project whole by wholeplatform.
the class AbstractTemplateManager method create.
public IEntity create(ITemplate template) {
ModelBuilderOperation op = new ModelBuilderOperation();
template.apply(op);
return op.wGetResult();
}
use of org.whole.lang.builders.ModelBuilderOperation in project whole by wholeplatform.
the class JSONPersistencesTest method testStreamAndBuildParserEquivalence.
@Test
public void testStreamAndBuildParserEquivalence() throws Exception {
IEntity sampleModelByFactory = JSONSourcePersistenceKit.instance().readModel(new StreamPersistenceProvider(getClass().getResourceAsStream("sample.json")));
ModelBuilderOperation op = new ModelBuilderOperation();
new JSONParserTemplateFactory(new JsonFactory().createParser(sampleString)).apply(op);
IEntity sampleModelByBuilder = ReflectionFactory.makeRootEntity(op.wGetResult());
assertTrue(Matcher.match(sampleModelByFactory, sampleModelByBuilder));
}
Aggregations