use of org.whole.lang.model.InternalIEntity in project whole by wholeplatform.
the class ReflectionFactory method makeRootEntity.
public static <E extends IEntity> E makeRootEntity(E entity, IFragmentModel parentFragmentModel) {
IFragmentModel fragmentModel = getLanguageKit(entity).createFragmentModel();
if (parentFragmentModel != NullFragmentModel.instance)
fragmentModel.setCompoundModel(parentFragmentModel.getCompoundModel());
((InternalIEntity) entity).wSetModel(fragmentModel);
return entity;
}
use of org.whole.lang.model.InternalIEntity in project whole by wholeplatform.
the class GenericCloneVisitor method applyClone.
public void applyClone(IEntity entity) {
IEntity entityClone = ((InternalIEntity) entity).wShallowClone();
setClone(entity, entityClone);
setChildrenAndAspects(entity, entityClone);
setResult(entityClone);
}
use of org.whole.lang.model.InternalIEntity in project whole by wholeplatform.
the class ReflectionServer method getPid.
public Serializable getPid(IEntity entity) {
Serializable pid = entity.wGetPid();
if (pid == null) {
pid = getFreshPid();
((InternalIEntity) entity).wSetPid(pid);
pidEntityMap.put(pid, entity);
if (!EntityUtils.hasParent(entity))
rootEntities.add(entity);
}
return pid;
}
use of org.whole.lang.model.InternalIEntity in project whole by wholeplatform.
the class ReflectionServer method replaceEntity.
public IEntity replaceEntity(IEntity targetEntity, IEntity sourceEntity) {
// FIXME move pid from old to newChild ?
((InternalIEntity) sourceEntity).wSetPid(targetEntity.wGetPid());
// TODO replace opposite references
// add as arguments
IEntity parentEntity = targetEntity.wGetParent();
int index = parentEntity.wIndexOf(targetEntity);
parentEntity.wSet(index, sourceEntity);
return sourceEntity;
}
use of org.whole.lang.model.InternalIEntity in project whole by wholeplatform.
the class HistoryInvariantsTest method testModelCloneHistory.
@Category(SlowTests.class)
@Test
public void testModelCloneHistory() {
performChanges(model);
IEntity model2 = EntityUtils.clone(model);
IEntityIterator<IEntity> i = IteratorFactory.descendantOrSelfIterator();
i.reset(model2);
for (IEntity e : i) {
ICommand cmd = ((InternalIEntity) e).wGetBindingCommand();
Assert.assertTrue(cmd.getKind() == CommandKind.NULL);
cmd = ((InternalIEntity) e).wGetLastCommand();
if (cmd.getKind() != CommandKind.NULL)
Assert.assertTrue(cmd.getKind() == CommandKind.NULL);
}
Assert.assertTrue(Matcher.match(model2, model));
}
Aggregations