use of org.whole.lang.java.util.JavaStoreProducerBuilder 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.java.util.JavaStoreProducerBuilder in project whole by wholeplatform.
the class PersistenceTest method testSingleBuilder2Java.
@Test
public void testSingleBuilder2Java() {
ModelBuilderOperation op = new ModelBuilderOperation();
JavaStoreProducerBuilderOperation javaOp = new JavaStoreProducerBuilderOperation(op);
((JavaStoreProducerBuilder) javaOp.wGetBuilder()).buildStartCompilationUnit("test", "Test");
try {
Properties props = PropertiesUtils.translate(System.getProperties());
props.getEntries().wAdd(0, createResolver(PropertiesEntityDescriptorEnum.Property));
new ModelTemplate(props).apply(javaOp);
} catch (IOException e) {
e.printStackTrace();
}
// new TopDownTraversal(new ModelsModel().create()).apply(javaOp);
((JavaStoreProducerBuilder) javaOp.wGetBuilder()).buildEndCompilationUnit();
// new ModelsModel().apply(new JavaStoreProducerBuilderOperation(op));
IEntity model = op.wGetResult();
PrettyPrinterOperation.prettyPrint(model);
}
Aggregations