use of org.whole.lang.pojo.model.Name in project whole by wholeplatform.
the class PojoUtils method getReadOnlyFields.
public static Set<Name> getReadOnlyFields(PojoDeclaration pojoDeclaration) {
Set<Name> readOnlyFields = new HashSet<Name>();
IBindingManager bindings = BindingManagerFactory.instance.createArguments();
Expression findAllReadOnlyFields = (Expression) PojoTemplateManager.instance().create("findAllReadOnlyFields");
for (Name readOnlyField : BehaviorUtils.<Name>compileAndLazyEvaluate(findAllReadOnlyFields, pojoDeclaration, bindings)) readOnlyFields.add(readOnlyField);
return readOnlyFields;
}
use of org.whole.lang.pojo.model.Name in project whole by wholeplatform.
the class PojoUtils method findConstructor.
public static Constructor findConstructor(PojoDeclaration pojoDeclaration) {
IBindingManager bindings = BindingManagerFactory.instance.createArguments();
Expression findParameterByTemplate = (Expression) PojoTemplateManager.instance().create("findParameterByTemplate");
List<Constructor> constructors = getConstructors(pojoDeclaration);
int[] supportedFields = new int[constructors.size()];
Expression findAllReadOnlyFields = (Expression) PojoTemplateManager.instance().create("findAllReadOnlyFields");
IEntityIterator<Name> iterator = BehaviorUtils.<Name>compileAndLazyEvaluate(findAllReadOnlyFields, pojoDeclaration, bindings);
int readOnlyFieldCount = 0;
while (iterator.hasNext()) {
iterator.next();
for (int i = 0; i < supportedFields.length; i++) if (BehaviorUtils.evaluateFirstResult(findParameterByTemplate, constructors.get(i), bindings) != null)
supportedFields[i]++;
readOnlyFieldCount++;
}
for (int i = 0; i < supportedFields.length; i++) if (supportedFields[i] >= readOnlyFieldCount)
return constructors.get(i);
return constructors.get(supportedFields.length - 1);
}
use of org.whole.lang.pojo.model.Name in project whole by wholeplatform.
the class PojoNormalizerVisitor method createDefaultTemplateInProperties.
public static void createDefaultTemplateInProperties(Library entity, IBindingManager bindings) {
Path findAllPropertiesWithoutTemplate = (Path) PojoTemplateManager.instance().create("findAllPropertiesWithoutTemplate");
bindings.wEnterScope();
for (Property property : BehaviorUtils.<Property>compileAndLazyEvaluate(findAllPropertiesWithoutTemplate, entity, bindings)) property.setTemplate((Name) EntityUtils.clone(bindings.wGet("name")));
bindings.wExitScope();
}
use of org.whole.lang.pojo.model.Name in project whole by wholeplatform.
the class PojoArtifactsGeneratorVisitor method visit.
@Override
public void visit(Library library) {
Name libraryName = library.getName();
if (!EntityUtils.isNotResolver(libraryName))
throw new VisitException("No library name");
String modelFileName = DataTypeUtils.getAsPersistenceString(libraryName) + "Model";
Model model = PojoMappingUtils.getModel(library);
env().wDefValue("modelFileName", modelFileName);
env().wDef("modelFileContent", model);
IEntity ws = ModelsArtifactsTemplateManager.instance().create("ModelFileArtifact");
Matcher.substitute(ws, env(), false);
ArtifactsUtils.moveArtifactsIntoWorkspace(ws, env());
}
use of org.whole.lang.pojo.model.Name in project whole by wholeplatform.
the class PojoUtils method findProductDeclarationByTemplateName.
public static ProductDeclaration findProductDeclarationByTemplateName(EntityDescriptor<?> ed, Library library) {
PojoEntityFactory pef = PojoEntityFactory.instance;
Expression findProductDeclarationByTemplateName = (Expression) PojoTemplateManager.instance().create("findProductDeclarationByTemplateName");
Name templateName = pef.createName(ed.getName());
IBindingManager bindings = BindingManagerFactory.instance.createArguments();
bindings.wDef("templateName", templateName);
return BehaviorUtils.evaluateFirstResult(findProductDeclarationByTemplateName, library, bindings);
}
Aggregations