use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.
the class ArtifactsSynchronizerVisitor method createFilesystemModel.
private IEntity createFilesystemModel(IArtifactsEntity model, IEntity basePath, boolean append) {
T parentContext = getResource();
IEntity artifact = basePath;
if (basePath != null) {
parentContext = getArtifactsOperations().getParent(parentContext);
if (getArtifactsOperations().getChild(parentContext, basePath) == null)
throw new IllegalArgumentException("invalid root resource");
while (artifact != null && EntityUtils.isNotResolver(artifact) && !EntityUtils.isVariable(artifact)) {
parentContext = getArtifactsOperations().getChild(parentContext, artifact);
if (parentContext == null)
break;
IEntity children = getChildren(artifact);
artifact = children.wIsEmpty() ? null : children.wGet(0);
}
}
if (parentContext == null) {
// cannot find path on file system
if (artifact == basePath)
// no file system root at all
getChildren(basePath).wRemove(0);
else
// partial file system path
artifact.wGetParent().wRemove(artifact);
} else {
// empty path or exists on file system
IEntity fsModel = getArtifactsOperations().toArtifactsModel(parentContext);
if (append && artifact != basePath) {
IBindingManager bindings = BindingManagerFactory.instance.createBindingManager();
IEntityIterator<IEntity> iterator = IteratorFactory.childIterator();
iterator.reset(getChildren(fsModel));
for (IEntity child : iterator) {
bindings.wDef(SUB_TREE_ROOT, child);
iterator.remove();
Matcher.substitute(basePath, bindings, false);
}
Matcher.removeVars(basePath, true);
} else
basePath = fsModel;
}
return basePath;
}
use of org.whole.lang.bindings.IBindingManager 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.bindings.IBindingManager 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.bindings.IBindingManager in project whole by wholeplatform.
the class SQLInterpreterVisitor method visit.
@Override
public void visit(ISQLEntity entity) {
if (statement != null)
return;
try {
if (!Matcher.isAssignableAsIsFrom(SQLEntityDescriptorEnum.SQLStatement, entity) && !Matcher.match(SQLEntityDescriptorEnum.SQLStatements, entity))
throw new IllegalArgumentException("cannot interpret.");
IBindingManager env = getBindings();
if (!env.wIsSet("connection"))
throw new IllegalArgumentException("database connection undefined.");
connection = (Connection) env.wGetValue("connection");
statement = connection.createStatement();
} catch (Exception e) {
throw new VisitException(SQL_INTERPRETER_ERROR_MESSAGE, e);
}
}
use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.
the class AbstractXsiPersistenceKit method doReadModel.
@Override
protected IEntity doReadModel(IPersistenceProvider pp) throws Exception {
IBindingManager bm = pp.getBindings();
ModelBuilderOperation mop = new ModelBuilderOperation(RegistryConfigurations.RESOLVER);
IBuilderOperation xsiBuilderOperation = getBuilderOperation(mop, bm);
bm.wDefValue("mergeCDataSect", true);
XmlNormalizerBuilderOperation normalizerOp = new XmlNormalizerBuilderOperation(xsiBuilderOperation, bm);
SaxConsumerHandler.parse(pp.getInputStream(), pp.getEncoding(), normalizerOp);
return mop.wGetResult();
}
Aggregations