use of org.whole.lang.model.IEntity in project whole by wholeplatform.
the class IEntityIterator method evaluate.
public default E evaluate(IEntity self, IBindingManager bm) {
IEntity oldSelfEntity = bm.wGet("self");
bm.wDef("self", self);
setBindings(bm);
reset(self);
E result = evaluateRemaining();
if (oldSelfEntity == null && bm.wGet("self") == self)
bm.wUnset("self");
return result;
}
use of org.whole.lang.model.IEntity in project whole by wholeplatform.
the class IEntityIterator method evaluateFirst.
public default E evaluateFirst(IEntity self, IBindingManager bm) {
IEntity oldSelfEntity = bm.wGet("self");
bm.wDef("self", self);
setBindings(bm);
reset(self);
E result = evaluateNext();
if (oldSelfEntity == null && bm.wGet("self") == self)
bm.wUnset("self");
return result;
}
use of org.whole.lang.model.IEntity in project whole by wholeplatform.
the class AncestorReverseIterator method getCollectionIterable.
@Override
protected Iterable<?> getCollectionIterable(IEntity entity) {
List<IEntity> ancestors = new ArrayList<IEntity>();
IEntityIterator<IEntity> i = IteratorFactory.ancestorIterator();
i.reset(entity);
for (IEntity parent : i) ancestors.add(parent);
Collections.reverse(ancestors);
return ancestors;
}
use of org.whole.lang.model.IEntity in project whole by wholeplatform.
the class AbstractEntityRegistryConfiguration method enforceMandatoryFeatures.
public static void enforceMandatoryFeatures(IEntityRegistry er, EntityDescriptor<?> ed, IEntity prototype, boolean[] isEnforced) {
if (isEnforced[ed.getOrdinal()])
return;
isEnforced[ed.getOrdinal()] = true;
if (ed.getEntityKind().isSimple()) {
List<FeatureDescriptor> eds = ed.getEntityFeatureDescriptors();
for (int i = 0, size = eds.size(); i < size; i++) {
FeatureDescriptor efd = eds.get(i);
EntityDescriptor<?> fed = efd.getEntityDescriptor();
if (fed.isPolymorphic() || efd.isOptional() || efd.isReference())
continue;
IEntity child = prototype.wGet(i);
if (!EntityUtils.isResolver(child))
continue;
if (fed.isAbstract())
continue;
child = er.get(fed);
enforceMandatoryFeatures(er, fed, child, isEnforced);
child = EntityUtils.clone(child);
prototype.wSet(i, child);
// if (fed.getEntityKind().isComposite() && !fed.getEntityFeatureDescriptor(0).isOptional())
// try {
// child.wAdd(CommonsEntityAdapterFactory.createResolver(fed.getEntityDescriptor(0)));
// } catch (UnsupportedOperationException e) {
// //FIXME workaround for Map entity
// }
}
// } else if (ed.getEntityKind().isComposite() && !ed.getEntityFeatureDescriptor(0).isOptional()) {
// try {
// prototype.wAdd(CommonsEntityAdapterFactory.createResolver(ed.getEntityDescriptor(0)));
// } catch (UnsupportedOperationException e) {
// //FIXME workaround for Map entity
// }
}
}
use of org.whole.lang.model.IEntity in project whole by wholeplatform.
the class AbstractCollectIterator method next.
public IEntity next() {
IEntity result = lookahead();
if (result == null)
throw new NoSuchElementException();
nextEntity = null;
return result;
}
Aggregations