You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2020/01/15 13:29:23 UTC
[isis] branch master updated: ISIS-2158: remove
ObjectMarshaller/Unmarshaller (no longer used)
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/master by this push:
new b1dccdc ISIS-2158: remove ObjectMarshaller/Unmarshaller (no longer used)
b1dccdc is described below
commit b1dccdc5b6672799eeb1d1bf68d62dac32b19322
Author: Andi Huber <ah...@apache.org>
AuthorDate: Wed Jan 15 14:29:13 2020 +0100
ISIS-2158: remove ObjectMarshaller/Unmarshaller (no longer used)
---
.../model/mementos/ActionParameterMemento.java | 7 -
.../mementos/ObjectAdapterMemento_Legacy.java | 571 ---------------------
.../viewer/services/mementos/CollectionData.java | 55 --
.../viewer/services/mementos/ObjectMarshaller.java | 153 ------
.../services/mementos/ObjectMementoLegacy.java | 83 +--
.../mementos/ObjectMementoServiceWicket.java | 14 +-
.../services/mementos/ObjectUnmarshaller.java | 293 -----------
.../viewer/services/mementos/StandaloneData.java | 70 ---
8 files changed, 19 insertions(+), 1227 deletions(-)
diff --git a/viewers/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/mementos/ActionParameterMemento.java b/viewers/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/mementos/ActionParameterMemento.java
index 1a25d1c..b9a5146 100644
--- a/viewers/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/mementos/ActionParameterMemento.java
+++ b/viewers/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/mementos/ActionParameterMemento.java
@@ -41,13 +41,6 @@ public class ActionParameterMemento implements Serializable {
private transient ObjectActionParameter actionParameter;
- public ActionParameterMemento(
- final ActionMemento actionMemento,
- final int number,
- final SpecificationLoader specificationLoader) {
- this(actionMemento, number, actionParameterFor(actionMemento, number, specificationLoader));
- }
-
public ActionParameterMemento(final ObjectActionParameter actionParameter) {
this(new ActionMemento(actionParameter.getAction()), actionParameter.getNumber(), actionParameter);
}
diff --git a/viewers/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/mementos/ObjectAdapterMemento_Legacy.java b/viewers/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/mementos/ObjectAdapterMemento_Legacy.java
deleted file mode 100644
index 81e494d..0000000
--- a/viewers/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/mementos/ObjectAdapterMemento_Legacy.java
+++ /dev/null
@@ -1,571 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.wicket.model.mementos;
-
-final class ObjectAdapterMemento_Legacy /*implements ObjectAdapterMemento*/ {
-
- // private static final long serialVersionUID = 1L;
- //
- // /**
- // * Factory method
- // */
- // public static ObjectAdapterMemento_Legacy ofAdapter(@Nullable final ObjectAdapter adapter) {
- // if (adapter == null) {
- // return null;
- // }
- // final Object object = adapter.getPojo();
- // if(object == null) {
- // return null;
- // }
- // return new ObjectAdapterMemento_Legacy(adapter);
- // }
- //
- // /**
- // * Factory method
- // */
- // public static ObjectAdapterMemento_Legacy ofRootOid(final RootOid rootOid) {
- // return new ObjectAdapterMemento_Legacy(rootOid);
- // }
- //
- // /**
- // * Factory method
- // */
- // public static ObjectAdapterMemento_Legacy ofMementoList(
- // final Collection<ObjectAdapterMemento> list,
- // final ObjectSpecId objectSpecId) {
- //
- // return list != null
- // ? new ObjectAdapterMemento_Legacy(_Lists.newArrayList(list), objectSpecId)
- // : null;
- // }
- //
- // enum Sort {
- // /**
- // * represents a single object
- // */
- // SCALAR {
- //
- // @Override
- // public ObjectAdapter asAdapter(
- // final ObjectAdapterMemento oam,
- // final ConcurrencyChecking concurrencyChecking,
- // final SpecificationLoader specificationLoader) {
- //
- // return ((ObjectAdapterMemento_Legacy)oam)
- // .type.recreateAdapter(oam, concurrencyChecking, specificationLoader);
- // }
- //
- // @Override
- // public int hashCode(final ObjectAdapterMemento_Legacy oam) {
- // return oam.type.hashCode(oam);
- // }
- //
- // @Override
- // public boolean equals(final ObjectAdapterMemento_Legacy oam, final Object other) {
- // if (!(other instanceof ObjectAdapterMemento_Legacy)) {
- // return false;
- // }
- // final ObjectAdapterMemento_Legacy otherOam = (ObjectAdapterMemento_Legacy) other;
- // if(otherOam.sort != SCALAR) {
- // return false;
- // }
- // return oam.type.equals(oam, (ObjectAdapterMemento_Legacy) other);
- // }
- //
- // @Override
- // public String asString(final ObjectAdapterMemento_Legacy oam) {
- // return oam.type.toString(oam);
- // }
- // },
- // /**
- // * represents a list of objects
- // */
- // VECTOR {
- //
- // @Override
- // public ObjectAdapter asAdapter(
- // final ObjectAdapterMemento oam,
- // final ConcurrencyChecking concurrencyChecking,
- // final SpecificationLoader specificationLoader) {
- //
- // val oap = IsisContext.getObjectAdapterProvider();
- //
- // final List<Object> listOfPojos = _NullSafe.stream(oam.getList())
- // .filter(_NullSafe::isPresent)
- // .map(ObjectAdapterMemento::getObjectAdapter)
- // .filter(_NullSafe::isPresent)
- // .map(ObjectAdapter::getPojo)
- // .filter(_NullSafe::isPresent)
- // .collect(Collectors.toList());
- //
- // return oap.adapterFor(listOfPojos);
- // }
- //
- // @Override
- // public int hashCode(final ObjectAdapterMemento_Legacy oam) {
- // return oam.list.hashCode();
- // }
- //
- // @Override
- // public boolean equals(final ObjectAdapterMemento_Legacy oam, final Object other) {
- // if (!(other instanceof ObjectAdapterMemento_Legacy)) {
- // return false;
- // }
- // final ObjectAdapterMemento_Legacy otherOam = (ObjectAdapterMemento_Legacy) other;
- // if(otherOam.sort != VECTOR) {
- // return false;
- // }
- // return oam.list.equals(otherOam.list);
- // }
- //
- // @Override
- // public String asString(final ObjectAdapterMemento_Legacy oam) {
- // return oam.list.toString();
- // }
- // };
- //
- // void ensure(final Sort sort) {
- // if(this == sort) {
- // return;
- // }
- // throw new IllegalStateException("Memento is not for " + sort);
- // }
- //
- // public abstract ObjectAdapter asAdapter(
- // final ObjectAdapterMemento oam,
- // final ConcurrencyChecking concurrencyChecking,
- // final SpecificationLoader specificationLoader);
- //
- // public abstract int hashCode(final ObjectAdapterMemento_Legacy oam);
- //
- // public abstract boolean equals(final ObjectAdapterMemento_Legacy oam, final Object other);
- //
- // public abstract String asString(final ObjectAdapterMemento_Legacy oam);
- // }
- //
- // enum Type {
- // /**
- // * The {@link ObjectAdapter} that this is the memento for directly has
- // * an {@link EncodableFacet} (it is almost certainly a value), and so is
- // * stored directly.
- // */
- // ENCODEABLE {
- // @Override
- // ObjectAdapter recreateAdapter(
- // final ObjectAdapterMemento oam,
- // final ConcurrencyChecking concurrencyChecking,
- // final SpecificationLoader specificationLoader) {
- //
- // ObjectSpecId objectSpecId = oam.getObjectSpecId();
- // ObjectSpecification objectSpec = SpecUtils.getSpecificationFor(objectSpecId, specificationLoader);
- // final EncodableFacet encodableFacet = objectSpec.getFacet(EncodableFacet.class);
- // return encodableFacet.fromEncodedString(((ObjectAdapterMemento_Legacy)oam).encodableValue);
- // }
- //
- // @Override
- // public boolean equals(ObjectAdapterMemento_Legacy oam, ObjectAdapterMemento_Legacy other) {
- // return other.type == ENCODEABLE && oam.encodableValue.equals(other.encodableValue);
- // }
- //
- // @Override
- // public int hashCode(ObjectAdapterMemento_Legacy oam) {
- // return oam.encodableValue.hashCode();
- // }
- //
- // @Override
- // public String toString(final ObjectAdapterMemento_Legacy oam) {
- // return oam.encodableValue;
- // }
- //
- // @Override
- // public void resetVersion(
- // ObjectAdapterMemento_Legacy objectAdapterMemento,
- // final SpecificationLoader specificationLoader) {
- // }
- // },
- // /**
- // * The {@link ObjectAdapter} that this is for is already known by its
- // * (persistent) {@link Oid}.
- // */
- // PERSISTENT {
- // @Override
- // ObjectAdapter recreateAdapter(
- // final ObjectAdapterMemento oam,
- // ConcurrencyChecking concurrencyChecking,
- // final SpecificationLoader specificationLoader) {
- //
- // val persistentOidStr = ((ObjectAdapterMemento_Legacy)oam).persistentOidStr;
- //
- // val rootOid = Oid.unmarshaller().unmarshal(persistentOidStr, RootOid.class);
- // try {
- // val persistenceSession = IsisContext.getPersistenceSession().orElse(null);
- // final ObjectAdapter adapter = persistenceSession.adapterFor(rootOid, concurrencyChecking);
- // return adapter;
- //
- // } finally {
- // // a side-effect of AdapterManager#adapterFor(...) is that it will update the oid
- // // with the correct version, even when there is a concurrency exception
- // // we copy this updated oid string into our memento so that, if we retry,
- // // we will succeed second time around
- //
- // ((ObjectAdapterMemento_Legacy)oam).persistentOidStr = rootOid.enString();
- // }
- // }
- //
- // @Override
- // public void resetVersion(
- // final ObjectAdapterMemento_Legacy oam,
- // final SpecificationLoader specificationLoader) {
- // // REVIEW: this may be redundant because recreateAdapter also guarantees the version will be reset.
- // final ObjectAdapter adapter = recreateAdapter(
- // oam, ConcurrencyChecking.NO_CHECK, specificationLoader);
- // Oid oid = adapter.getOid();
- // oam.persistentOidStr = oid.enString();
- // }
- //
- // @Override
- // public boolean equals(ObjectAdapterMemento_Legacy oam, ObjectAdapterMemento_Legacy other) {
- // return other.type == PERSISTENT && oam.persistentOidStr.equals(other.persistentOidStr);
- // }
- //
- // @Override
- // public int hashCode(ObjectAdapterMemento_Legacy oam) {
- // return oam.persistentOidStr.hashCode();
- // }
- //
- // @Override
- // public String toString(final ObjectAdapterMemento_Legacy oam) {
- // return oam.persistentOidStr;
- // }
- //
- // },
- // /**
- // * Uses Isis' own {@link Memento}, to capture the state of a transient
- // * object.
- // */
- // TRANSIENT {
- // /**
- // * {@link ConcurrencyChecking} is ignored for transients.
- // */
- // @Override
- // ObjectAdapter recreateAdapter(
- // final ObjectAdapterMemento oam,
- // final ConcurrencyChecking concurrencyChecking,
- // final SpecificationLoader specificationLoader) {
- //
- // return ((ObjectAdapterMemento_Legacy)oam).transientMemento.recreateObject();
- // }
- //
- // @Override
- // public boolean equals(ObjectAdapterMemento_Legacy oam, ObjectAdapterMemento_Legacy other) {
- // return other.type == TRANSIENT && oam.transientMemento.equals(other.transientMemento);
- // }
- //
- // @Override
- // public int hashCode(ObjectAdapterMemento_Legacy oam) {
- // return oam.transientMemento.hashCode();
- // }
- //
- // @Override
- // public String toString(final ObjectAdapterMemento_Legacy oam) {
- // return oam.transientMemento.toString();
- // }
- //
- // @Override
- // public void resetVersion(
- // final ObjectAdapterMemento_Legacy objectAdapterMemento,
- // final SpecificationLoader specificationLoader) {
- // }
- // };
- //
- // abstract ObjectAdapter recreateAdapter(
- // final ObjectAdapterMemento nom,
- // final ConcurrencyChecking concurrencyChecking,
- // final SpecificationLoader specificationLoader);
- //
- // public abstract boolean equals(ObjectAdapterMemento_Legacy oam, ObjectAdapterMemento_Legacy other);
- // public abstract int hashCode(ObjectAdapterMemento_Legacy objectAdapterMemento);
- //
- // public abstract String toString(ObjectAdapterMemento_Legacy adapterMemento);
- //
- // public abstract void resetVersion(
- // ObjectAdapterMemento_Legacy objectAdapterMemento,
- // final SpecificationLoader specificationLoader);
- // }
- //
- //
- //
- // private final Sort sort;
- // private final ObjectSpecId objectSpecId;
- //
- // /**
- // * Populated only if {@link #getSort() sort} is {@link Sort#SCALAR scalar}
- // */
- // private Type type;
- //
- // /**
- // * Populated only if {@link #getSort() sort} is {@link Sort#SCALAR scalar}
- // */
- // @SuppressWarnings("unused")
- // private String titleHint;
- //
- // /**
- // * The current value, if {@link Type#ENCODEABLE}; will be <tt>null</tt> otherwise.
- // *
- // * <p>
- // * Also, populated only if {@link #getSort() sort} is {@link Sort#SCALAR scalar}
- // */
- // private String encodableValue;
- //
- // /**
- // * The current value, if {@link Type#PERSISTENT}, will be <tt>null</tt> otherwise.
- // *
- // * <p>
- // * Also, populated only if {@link #getSort() sort} is {@link Sort#SCALAR scalar}
- // */
- // private String persistentOidStr;
- //
- // /**
- // * The current value, if {@link Type#PERSISTENT}, will be <tt>null</tt> otherwise.
- // *
- // * <p>
- // * Also, populated only if {@link #getSort() sort} is {@link Sort#SCALAR scalar}
- // */
- // private Bookmark bookmark;
- //
- // /**
- // * Only populated for {@link ObjectAdapter#getPojo() domain object}s that implement {@link HintStore.HintIdProvider}.
- // */
- // private String hintId;
- //
- // /**
- // * The current value, if {@link Type#TRANSIENT}, will be <tt>null</tt> otherwise.
- // *
- // * <p>
- // * Also, populated only if {@link #getSort() sort} is {@link Sort#SCALAR scalar}
- // */
- // private Memento transientMemento;
- //
- // /**
- // * populated only if {@link #getSort() sort} is {@link Sort#VECTOR vector}
- // */
- // private ArrayList<ObjectAdapterMemento> list;
- //
- // public ObjectAdapterMemento_Legacy(
- // final ArrayList<ObjectAdapterMemento> list,
- // final ObjectSpecId objectSpecId) {
- //
- // this.sort = Sort.VECTOR;
- // this.list = list;
- // this.objectSpecId = objectSpecId;
- // }
- //
- // private ObjectAdapterMemento_Legacy(final RootOid rootOid) {
- //
- // if (rootOid.isTransient()) {
- // throw _Exceptions.unexpectedCodeReach();
- // }
- //
- // this.objectSpecId = rootOid.getObjectSpecId();
- //
- // //TODO[2112] do we ever need to create ENCODEABLE here?
- // val spec = IsisContext.getSpecificationLoader().lookupBySpecId(objectSpecId);
- // if(spec!=null && spec.isEncodeable()) {
- // this.sort = Sort.SCALAR;
- // this.type = Type.ENCODEABLE;
- // this.encodableValue = rootOid.getIdentifier();
- // return;
- // }
- //
- // this.sort = Sort.SCALAR;
- // this.type = Type.PERSISTENT;
- //
- // this.persistentOidStr = rootOid.enString();
- // this.bookmark = rootOid.asBookmark();
- // }
- //
- // private ObjectAdapterMemento_Legacy(final ObjectAdapter adapter) {
- //
- // requires(adapter, "adapter");
- //
- // this.sort = Sort.SCALAR;
- // final ObjectSpecification specification = adapter.getSpecification();
- // objectSpecId = specification.getSpecId();
- //
- // final EncodableFacet encodableFacet = specification.getFacet(EncodableFacet.class);
- // final boolean isEncodable = encodableFacet != null;
- // if (isEncodable) {
- // encodableValue = encodableFacet.toEncodedString(adapter);
- // type = Type.ENCODEABLE;
- // return;
- // }
- //
- // final RootOid rootOid = (RootOid) adapter.getOid();
- // if (rootOid.isTransient()) {
- // transientMemento = new Memento(adapter);
- // type = Type.TRANSIENT;
- // return;
- // }
- //
- // persistentOidStr = rootOid.enString();
- // bookmark = rootOid.asBookmark();
- // if(adapter.getPojo() instanceof HintStore.HintIdProvider) {
- // HintStore.HintIdProvider provider = (HintStore.HintIdProvider) adapter.getPojo();
- // this.hintId = provider.hintId();
- // }
- // type = Type.PERSISTENT;
- // }
- //
- // public Sort getSort() {
- // return sort;
- // }
- //
- // public ArrayList<ObjectAdapterMemento> getList() {
- // ensureVector();
- // return list;
- // }
- //
- //
- // private void resetVersion_legacy(
- // final SpecificationLoader specificationLoader) {
- //
- // ensureScalar();
- // type.resetVersion(this, specificationLoader);
- // }
- //
- //
- // public Bookmark asBookmarkIfSupported() {
- // ensureScalar();
- // return bookmark;
- // }
- //
- // public Bookmark asHintingBookmarkIfSupported() {
- // Bookmark bookmark = asBookmarkIfSupported();
- // return hintId != null && bookmark != null
- // ? new HintStore.BookmarkWithHintId(bookmark, hintId)
- // : bookmark;
- // }
- //
- //// /**
- //// * Lazily looks up {@link ObjectAdapter} if required.
- //// *
- //// * <p>
- //// * For transient objects, be aware that calling this method more than once
- //// * will cause the underlying {@link ObjectAdapter} to be recreated,
- //// * overwriting any changes that may have been made. In general then it's
- //// * best to call once and then hold onto the value thereafter. Alternatively,
- //// * can call {@link #setAdapter(ObjectAdapter)} to keep this memento in sync.
- //// */
- //// private ObjectAdapter getObjectAdapter_legacy(
- //// final ConcurrencyChecking concurrencyChecking,
- //// final PersistenceSession persistenceSession,
- //// final SpecificationLoader specificationLoader) {
- //// return sort.asAdapter(this, concurrencyChecking, persistenceSession, specificationLoader);
- //// }
- //
- //// /**
- //// * Updates the memento if the adapter's state has changed.
- //// *
- //// * @param adapter
- //// */
- //// public void setAdapter(final ObjectAdapter adapter) {
- //// ensureScalar();
- //// init(adapter);
- //// }
- //
- // public ObjectSpecId getObjectSpecId() {
- // return objectSpecId;
- // }
- //
- //// /**
- //// * Analogous to {@link List#contains(Object)}, but does not perform
- //// * {@link ConcurrencyChecking concurrency checking} of the OID.
- //// */
- //// public boolean containedIn(
- //// List<ObjectAdapterMemento_Legacy> list,
- //// final PersistenceSession persistenceSession,
- //// final SpecificationLoader specificationLoader) {
- ////
- //// ensureScalar();
- ////
- //// // REVIEW: heavy handed, ought to be possible to just compare the OIDs
- //// // ignoring the concurrency checking
- //// final ObjectAdapter currAdapter = getObjectAdapter(ConcurrencyChecking.NO_CHECK, persistenceSession,
- //// specificationLoader);
- //// for (ObjectAdapterMemento_Legacy each : list) {
- //// if(each == null) {
- //// continue;
- //// }
- //// final ObjectAdapter otherAdapter = each.getObjectAdapter(
- //// ConcurrencyChecking.NO_CHECK, persistenceSession, specificationLoader);
- //// if(currAdapter == otherAdapter) {
- //// return true;
- //// }
- //// }
- //// return false;
- //// }
- //
- // @Override
- // public int hashCode() {
- // return sort.hashCode(this);
- // }
- //
- // @Override
- // public boolean equals(Object obj) {
- // return sort.equals(this, obj);
- // }
- //
- //
- // @Override
- // public String toString() {
- // return asString();
- // }
- //
- // public String asString() {
- // return sort.asString(this);
- // }
- //
- // private void ensureScalar() {
- // getSort().ensure(Sort.SCALAR);
- // }
- //
- // private void ensureVector() {
- // getSort().ensure(Sort.VECTOR);
- // }
- //
- // @Override
- // public ObjectAdapter getObjectAdapter() {
- //
- // val specLoader = IsisContext.getSpecificationLoader();
- //
- // if(type==null) {
- // return sort.asAdapter(this, ConcurrencyChecking.NO_CHECK, specLoader);
- // }
- //
- // // we use de-serialization for the remaining cases
- // return type.recreateAdapter(this, ConcurrencyChecking.NO_CHECK, specLoader);
- // }
- //
- // @Override
- // public void resetVersion() {
- // resetVersion_legacy(IsisContext.getSpecificationLoader());
- // }
-
-}
diff --git a/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/services/mementos/CollectionData.java b/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/services/mementos/CollectionData.java
deleted file mode 100644
index fa212b2..0000000
--- a/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/services/mementos/CollectionData.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.wicket.viewer.services.mementos;
-
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import org.apache.isis.core.commons.internal.base._NullSafe;
-import org.apache.isis.core.metamodel.adapter.oid.Oid;
-
-final class CollectionData extends Data {
-
- private final static long serialVersionUID = 1L;
- private final Data[] elements;
-
- public CollectionData(final Oid oid, final Data[] elements) {
- super(oid);
- this.elements = elements;
- }
-
- @Override
- public String toString() {
- return "("
- + streamElements()
- .map(data->""+data)
- .collect(Collectors.joining(","))
- + ")";
- }
-
- public Stream<Data> streamElements() {
- return _NullSafe.stream(elements);
- }
-
- public int getElementCount() {
- return _NullSafe.size(elements);
- }
-
-}
diff --git a/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/services/mementos/ObjectMarshaller.java b/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/services/mementos/ObjectMarshaller.java
deleted file mode 100644
index 000a0cf..0000000
--- a/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/services/mementos/ObjectMarshaller.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.wicket.viewer.services.mementos;
-
-import java.util.Set;
-
-import org.apache.isis.core.commons.exceptions.UnknownTypeException;
-import org.apache.isis.core.commons.internal.collections._Arrays;
-import org.apache.isis.core.commons.internal.collections._Sets;
-import org.apache.isis.core.commons.internal.exceptions._Exceptions;
-import org.apache.isis.core.metamodel.adapter.oid.Oid;
-import org.apache.isis.core.metamodel.consent.InteractionInitiatedBy;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
-import org.apache.isis.core.metamodel.facets.object.encodeable.EncodableFacet;
-import org.apache.isis.core.metamodel.facets.propcoll.accessor.PropertyOrCollectionAccessorFacet;
-import org.apache.isis.core.metamodel.facets.properties.update.modify.PropertySetterFacet;
-import org.apache.isis.core.metamodel.spec.ManagedObject;
-import org.apache.isis.core.metamodel.spec.feature.Contributed;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-
-import lombok.val;
-import lombok.extern.log4j.Log4j2;
-
-/**
- * converts a {@link ManagedObject} to serializable {@link Data}
- *
- * @since 2.0
- */
-@Log4j2
-final class ObjectMarshaller {
-
- Data toData(ManagedObject adapter) {
- val data = (adapter == null) ? null : createData(adapter);
- log.debug("created memento for {}", this);
- return data;
- }
-
- // -- HELPER
-
- private final transient Set<Oid> oids = _Sets.newHashSet();
-
- private Data createData(ManagedObject adapter) {
- if (adapter.getSpecification().isParentedOrFreeCollection() &&
- !adapter.getSpecification().isEncodeable()) {
- return createCollectionData(adapter);
- } else {
- return createObjectData(adapter);
- }
- }
-
- private Data createCollectionData(ManagedObject adapter) {
-
- final Data[] collData = CollectionFacet.Utils.streamAdapters(adapter)
- .map(this::createReferencedData)
- .collect(_Arrays.toArray(Data.class, CollectionFacet.Utils.size(adapter)));
-
- val elementOid = ManagedObject._identify(adapter);
-
- return new CollectionData(elementOid, collData);
- }
-
- private ObjectData createObjectData(ManagedObject adapter) {
- val oid = ManagedObject._identify(adapter);
- oids.add(oid);
- val spec = adapter.getSpecification();
- val data = new ObjectData(oid);
-
- spec.streamAssociations(Contributed.EXCLUDED)
- .filter(association->{
- if (association.isNotPersisted()) {
- if (association.isOneToManyAssociation()) {
- return false;
- }
- if (association.containsFacet(PropertyOrCollectionAccessorFacet.class) &&
- !association.containsFacet(PropertySetterFacet.class)) {
- log.debug("ignoring not-settable field {}", association.getName());
- return false;
- }
- }
- return true;
- })
- .forEach(association->{
- createAssociationData(adapter, data, association);
- });
-
- return data;
- }
-
- private void createAssociationData(ManagedObject adapter, ObjectData data, ObjectAssociation objectAssoc) {
- Object assocData;
- if (objectAssoc.isOneToManyAssociation()) {
- val collAdapter = objectAssoc.get(adapter, InteractionInitiatedBy.FRAMEWORK);
- assocData = createCollectionData(collAdapter);
- } else if (objectAssoc.getSpecification().isEncodeable()) {
- val encodableFacet = objectAssoc.getSpecification().getFacet(EncodableFacet.class);
- val value = objectAssoc.get(adapter, InteractionInitiatedBy.FRAMEWORK);
- assocData = encodableFacet.toEncodedString(value);
- } else if (objectAssoc.isOneToOneAssociation()) {
- val referencedAdapter = objectAssoc.get(adapter, InteractionInitiatedBy.FRAMEWORK);
- assocData = createReferencedData(referencedAdapter);
- } else {
- throw new UnknownTypeException(objectAssoc);
- }
- data.addField(objectAssoc.getId(), assocData);
- }
-
- private Data createReferencedData(ManagedObject referencedAdapter) {
- if (referencedAdapter == null) {
- return null;
- }
-
- val refOid = ManagedObject._identify(referencedAdapter);
-
- if (refOid == null) {
- throw _Exceptions.unexpectedCodeReach();
- }
-
- if (refOid.isValue()) {
- return new StandaloneData(refOid, referencedAdapter);
- }
-
- val refSpec = referencedAdapter.getSpecification();
-
- if (refSpec.isParented()) {
-
- if(!oids.contains(refOid)) {
- oids.add(refOid);
- return createObjectData(referencedAdapter);
- }
- }
-
- return new Data(refOid);
- }
-
-
-}
diff --git a/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/services/mementos/ObjectMementoLegacy.java b/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/services/mementos/ObjectMementoLegacy.java
index 9871136..718cbb7 100644
--- a/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/services/mementos/ObjectMementoLegacy.java
+++ b/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/services/mementos/ObjectMementoLegacy.java
@@ -21,7 +21,6 @@ package org.apache.isis.viewer.wicket.viewer.services.mementos;
import java.io.Serializable;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.List;
import java.util.function.Function;
@@ -72,28 +71,7 @@ final class ObjectMementoLegacy implements Serializable {
return new ObjectMementoLegacy(rootOid, specificationLoader);
}
- static ObjectMementoLegacy createForList(
- ArrayList<ObjectMementoLegacy> list,
- ObjectSpecId objectSpecId) {
-
- return new ObjectMementoLegacy(list, objectSpecId);
- }
-
- static ObjectMementoLegacy createForList(
- Collection<ObjectMementoLegacy> list,
- ObjectSpecId objectSpecId) {
-
- return list != null ? createForList(_Lists.newArrayList(list), objectSpecId) : null;
- }
-
- static ObjectMementoLegacy createForEncodeable(
- ObjectSpecId specId,
- String encodableValue) {
-
- return new ObjectMementoLegacy(specId, encodableValue);
- }
-
- enum Cardinality {
+ private enum Cardinality {
/**
* represents a single object
*/
@@ -102,10 +80,9 @@ final class ObjectMementoLegacy implements Serializable {
@Override
public ManagedObject asAdapter(
ObjectMementoLegacy memento,
- ObjectUnmarshaller objectUnmarshaller,
SpecificationLoader specificationLoader) {
- return memento.recreateStrategy.recreateObject(memento, objectUnmarshaller, specificationLoader);
+ return memento.recreateStrategy.recreateObject(memento, specificationLoader);
}
@Override
@@ -138,13 +115,12 @@ final class ObjectMementoLegacy implements Serializable {
@Override
public ManagedObject asAdapter(
ObjectMementoLegacy memento,
- ObjectUnmarshaller objectUnmarshaller,
SpecificationLoader specificationLoader) {
final List<Object> listOfPojos =
- _Lists.map(memento.list, Functions.toPojo(objectUnmarshaller));
+ _Lists.map(memento.list, Functions.toPojo(specificationLoader));
- return objectUnmarshaller.adapterForListOfPojos(listOfPojos);
+ return ManagedObject.of(specificationLoader::loadSpecification, listOfPojos);
}
@Override
@@ -179,7 +155,6 @@ final class ObjectMementoLegacy implements Serializable {
public abstract ManagedObject asAdapter(
ObjectMementoLegacy memento,
- ObjectUnmarshaller objectUnmarshaller,
SpecificationLoader specificationLoader);
public abstract int hashCode(ObjectMementoLegacy memento);
@@ -189,7 +164,7 @@ final class ObjectMementoLegacy implements Serializable {
public abstract String asString(ObjectMementoLegacy memento);
}
- enum RecreateStrategy {
+ private enum RecreateStrategy {
/**
* The {@link ObjectAdapter} that this is the memento for directly has
* an {@link EncodableFacet} (it is almost certainly a value), and so is
@@ -199,7 +174,6 @@ final class ObjectMementoLegacy implements Serializable {
@Override
public ManagedObject recreateObject(
ObjectMementoLegacy memento,
- ObjectUnmarshaller objectUnmarshaller,
SpecificationLoader specificationLoader) {
ObjectSpecId specId = memento.objectSpecId;
@@ -230,7 +204,6 @@ final class ObjectMementoLegacy implements Serializable {
@Override
public void resetVersion(
ObjectMementoLegacy memento,
- ObjectUnmarshaller objectUnmarshaller,
SpecificationLoader specificationLoader) {
}
},
@@ -242,7 +215,6 @@ final class ObjectMementoLegacy implements Serializable {
@Override
public ManagedObject recreateObject(
ObjectMementoLegacy memento,
- ObjectUnmarshaller objectUnmarshaller,
SpecificationLoader specificationLoader) {
RootOid rootOid = Oid.unmarshaller().unmarshal(memento.persistentOidStr, RootOid.class);
@@ -264,12 +236,10 @@ final class ObjectMementoLegacy implements Serializable {
@Override
public void resetVersion(
ObjectMementoLegacy memento,
- ObjectUnmarshaller objectUnmarshaller,
SpecificationLoader specificationLoader) {
//XXX REVIEW: this may be redundant because recreateAdapter also guarantees the version will be reset.
- final ManagedObject adapter = recreateObject(
- memento, objectUnmarshaller, specificationLoader);
+ final ManagedObject adapter = recreateObject(memento, specificationLoader);
Oid oid = ManagedObject._identify(adapter);
memento.persistentOidStr = oid.enString();
@@ -294,7 +264,6 @@ final class ObjectMementoLegacy implements Serializable {
public abstract ManagedObject recreateObject(
ObjectMementoLegacy memento,
- ObjectUnmarshaller objectUnmarshaller,
SpecificationLoader specificationLoader);
public abstract boolean equals(
@@ -307,7 +276,6 @@ final class ObjectMementoLegacy implements Serializable {
public abstract void resetVersion(
ObjectMementoLegacy memento,
- ObjectUnmarshaller objectUnmarshaller,
SpecificationLoader specificationLoader);
}
@@ -361,7 +329,7 @@ final class ObjectMementoLegacy implements Serializable {
*/
private ArrayList<ObjectMementoLegacy> list;
- public ObjectMementoLegacy(
+ private ObjectMementoLegacy(
ArrayList<ObjectMementoLegacy> list,
ObjectSpecId objectSpecId) {
@@ -435,25 +403,10 @@ final class ObjectMementoLegacy implements Serializable {
recreateStrategy = RecreateStrategy.LOOKUP;
}
- Cardinality getCardinality() {
+ private Cardinality getCardinality() {
return cardinality;
}
- ArrayList<ObjectMementoLegacy> getList() {
- ensureVector();
- return list;
- }
-
-
- void resetVersion(
- ObjectUnmarshaller objectUnmarshaller,
- SpecificationLoader specificationLoader) {
-
- ensureScalar();
- recreateStrategy.resetVersion(this, objectUnmarshaller, specificationLoader);
- }
-
-
Bookmark asBookmark() {
ensureScalar();
return bookmark;
@@ -476,9 +429,7 @@ final class ObjectMementoLegacy implements Serializable {
* best to call once and then hold onto the value thereafter. Alternatively,
* can call {@link #setAdapter(ManagedObject)} to keep this memento in sync.
*/
- ManagedObject reconstructObject(
- ObjectUnmarshaller objectUnmarshaller,
- SpecificationLoader specificationLoader) {
+ ManagedObject reconstructObject(SpecificationLoader specificationLoader) {
val spec = specificationLoader.loadSpecification(objectSpecId);
if(spec==null) {
@@ -491,7 +442,7 @@ final class ObjectMementoLegacy implements Serializable {
return spec.getMetaModelContext().lookupServiceAdapterById(objectSpecId.asString());
}
- return cardinality.asAdapter(this, objectUnmarshaller, specificationLoader);
+ return cardinality.asAdapter(this, specificationLoader);
}
/**
@@ -514,20 +465,19 @@ final class ObjectMementoLegacy implements Serializable {
*/
boolean containedIn(
List<ObjectMementoLegacy> mementos,
- ObjectUnmarshaller objectUnmarshaller,
SpecificationLoader specificationLoader) {
ensureScalar();
//XXX REVIEW: heavy handed, ought to be possible to just compare the OIDs
// ignoring the concurrency checking
- val currAdapter = reconstructObject(objectUnmarshaller, specificationLoader);
+ val currAdapter = reconstructObject(specificationLoader);
for (val memento : mementos) {
if(memento == null) {
continue;
}
- val otherAdapter = memento.reconstructObject(objectUnmarshaller, specificationLoader);
+ val otherAdapter = memento.reconstructObject(specificationLoader);
if(currAdapter == otherAdapter) {
return true;
}
@@ -561,15 +511,14 @@ final class ObjectMementoLegacy implements Serializable {
@NoArgsConstructor(access = AccessLevel.PRIVATE)
final static class Functions {
- public static Function<ObjectMementoLegacy, Object> toPojo(
- final ObjectUnmarshaller objectUnmarshaller) {
+ public static Function<ObjectMementoLegacy, Object> toPojo(SpecificationLoader specificationLoader) {
return memento->{
if(memento == null) {
return null;
}
val objectAdapter = memento
- .reconstructObject(objectUnmarshaller, objectUnmarshaller.getSpecificationLoader());
+ .reconstructObject(specificationLoader);
if(objectAdapter == null) {
return null;
}
@@ -583,9 +532,5 @@ final class ObjectMementoLegacy implements Serializable {
getCardinality().ensure(Cardinality.SCALAR);
}
- private void ensureVector() {
- getCardinality().ensure(Cardinality.VECTOR);
- }
-
}
diff --git a/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/services/mementos/ObjectMementoServiceWicket.java b/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/services/mementos/ObjectMementoServiceWicket.java
index c259ee9..e8251e8 100644
--- a/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/services/mementos/ObjectMementoServiceWicket.java
+++ b/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/services/mementos/ObjectMementoServiceWicket.java
@@ -60,7 +60,6 @@ public class ObjectMementoServiceWicket implements ObjectMementoService {
@Inject @Getter private SpecificationLoader specificationLoader;
@Inject private ObjectManager objectManager;
- private ObjectUnmarshaller objectUnmarshaller;
@Override
public ObjectMemento mementoForRootOid(RootOid rootOid) {
@@ -97,9 +96,6 @@ public class ObjectMementoServiceWicket implements ObjectMementoService {
if(memento==null) {
return null;
}
- if(objectUnmarshaller==null) {
- objectUnmarshaller = new ObjectUnmarshaller(objectManager, specificationLoader);
- }
if(memento instanceof ObjectMementoCollection) {
val objectMementoCollection = (ObjectMementoCollection) memento;
@@ -111,19 +107,19 @@ public class ObjectMementoServiceWicket implements ObjectMementoService {
.filter(_NullSafe::isPresent)
.collect(Collectors.toCollection(ArrayList::new));
- return objectUnmarshaller.adapterForListOfPojos(listOfPojos);
+ return ManagedObject.of(specificationLoader::loadSpecification, listOfPojos);
}
if(memento instanceof ObjectMementoAdapter) {
val objectMementoAdapter = (ObjectMementoAdapter) memento;
- return objectMementoAdapter.reconstructObject(objectUnmarshaller);
+ return objectMementoAdapter.reconstructObject(specificationLoader);
}
throw _Exceptions.unrecoverableFormatted("unsupported ObjectMemento type %s", memento.getClass());
}
@RequiredArgsConstructor(staticName = "of")
- static class ObjectMementoAdapter implements ObjectMemento {
+ private static class ObjectMementoAdapter implements ObjectMemento {
private static final long serialVersionUID = 1L;
@@ -149,8 +145,8 @@ public class ObjectMementoServiceWicket implements ObjectMementoService {
return delegate.getObjectSpecId();
}
- ManagedObject reconstructObject(ObjectUnmarshaller objectUnmarshaller) {
- return delegate.reconstructObject(objectUnmarshaller, objectUnmarshaller.getSpecificationLoader());
+ ManagedObject reconstructObject(SpecificationLoader specificationLoader) {
+ return delegate.reconstructObject(specificationLoader);
}
@Override
diff --git a/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/services/mementos/ObjectUnmarshaller.java b/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/services/mementos/ObjectUnmarshaller.java
deleted file mode 100644
index 5504c18..0000000
--- a/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/services/mementos/ObjectUnmarshaller.java
+++ /dev/null
@@ -1,293 +0,0 @@
-package org.apache.isis.viewer.wicket.viewer.services.mementos;
-
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Set;
-import java.util.function.Supplier;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import org.apache.isis.core.commons.exceptions.IsisException;
-import org.apache.isis.core.commons.internal.assertions._Assert;
-import org.apache.isis.core.commons.internal.exceptions._Exceptions;
-import org.apache.isis.core.metamodel.adapter.oid.Oid;
-import org.apache.isis.core.metamodel.adapter.oid.ParentedOid;
-import org.apache.isis.core.metamodel.adapter.oid.RootOid;
-import org.apache.isis.core.metamodel.consent.InteractionInitiatedBy;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
-import org.apache.isis.core.metamodel.facets.object.encodeable.EncodableFacet;
-import org.apache.isis.core.metamodel.facets.propcoll.accessor.PropertyOrCollectionAccessorFacet;
-import org.apache.isis.core.metamodel.facets.properties.update.modify.PropertySetterFacet;
-import org.apache.isis.core.metamodel.objectmanager.ObjectManager;
-import org.apache.isis.core.metamodel.objectmanager.create.ObjectCreator;
-import org.apache.isis.core.metamodel.objectmanager.load.ObjectLoader;
-import org.apache.isis.core.metamodel.spec.ManagedObject;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.Contributed;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
-import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
-import org.apache.isis.core.metamodel.specloader.SpecificationLoader;
-import org.apache.isis.core.runtime.persistence.adapter.PojoAdapter;
-import org.apache.isis.core.runtime.session.IsisSession;
-
-import static org.apache.isis.core.commons.internal.functions._Predicates.not;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import lombok.val;
-import lombok.extern.log4j.Log4j2;
-
-/**
- * Converts serializable {@link Data} back to a {@link ManagedObject}.
- *
- * @since 2.0
- */
-@RequiredArgsConstructor
-@Log4j2
-final class ObjectUnmarshaller {
-
- private final ObjectManager objectManager;
- @Getter private final SpecificationLoader specificationLoader;
-
- ManagedObject recreateObject(Data data) {
- if (data == null) {
- return null;
- }
- val spec = specificationLoader.lookupBySpecIdElseLoad(data.getObjectSpecId());
- val oid = data.getOid();
- return recreateObject(spec, oid, data);
- }
-
- ManagedObject adapterForListOfPojos(List<Object> listOfPojos) {
- return ManagedObject.of(specificationLoader::loadSpecification, listOfPojos);
- }
-
- // -- HELPER
-
- private ManagedObject recreateObject(ObjectSpecification spec, Oid oid, Data data) {
-
- ManagedObject adapter;
-
- if (spec.isParentedOrFreeCollection()) {
-
- final Supplier<Object> emptyCollectionPojoFactory =
- ()->instantiateAndInjectServices(spec);
-
- final Object collectionPojo = populateCollection(
- emptyCollectionPojoFactory,
- spec,
- (CollectionData) data);
-
-
- final ParentedOid collectionOid = (ParentedOid) oid;
- adapter = PojoAdapter.of(
- collectionPojo, collectionOid,
- IsisSession.currentOrElseNull());
-
- } else {
- _Assert.assertTrue("oid must be a RootOid representing an object because spec "
- + "is not a collection and cannot be a value", oid instanceof RootOid);
- RootOid typedOid = (RootOid) oid;
- // recreate an adapter for the original OID
- adapter = adapterForOid(typedOid);
-
- if (!(data instanceof ObjectData)) {
- throw new IsisException("Expected ObjectData but got " + data.getClass());
- }
-
- updateObject(adapter, (ObjectData)data);
- }
-
- if (log.isDebugEnabled()) {
- log.debug("recreated object {}", oid);
- }
- return adapter;
- }
-
- private Object instantiateAndInjectServices(ObjectSpecification spec) {
-
- val objectCreateRequest = ObjectCreator.Request.of(spec);
- return objectManager.createObject(objectCreateRequest);
- }
-
- private ManagedObject recreateReference(Data data) {
- // handle values
- if (data instanceof StandaloneData) {
- val standaloneData = (StandaloneData) data;
- return standaloneData.getAdapter(this::adapterForPojo, specificationLoader);
- }
-
- // reference to entity
-
- Oid oid = data.getOid();
- _Assert.assertTrue("can only create a reference to an entity", oid instanceof RootOid);
-
- val rootOid = (RootOid) oid;
- val referencedAdapter = adapterForOid(rootOid);
-
- if (data instanceof ObjectData) {
- val state = ManagedObject._entityState(referencedAdapter);
- if (state.isDetached()) {
- updateObject(referencedAdapter, (ObjectData)data);
- }
- }
- return referencedAdapter;
- }
-
-
-
- private void updateObject(final ManagedObject adapter, final ObjectData data) {
-
- val oid = objectManager.identifyObject(adapter);
-
- if (!Objects.equals(oid, data.getOid())) {
- throw new IllegalArgumentException(
- "This memento can only be used to update the ObjectAdapter with the Oid "
- + data.getOid() + " but is " + oid);
- }
-
- updateFieldsAndResolveState(adapter, data);
-
- if (log.isDebugEnabled()) {
- log.debug("object updated {}", oid);
- }
- }
-
- private Object populateCollection(
- final Supplier<Object> emptyCollectionPojoFactory,
- final ObjectSpecification collectionSpec,
- final CollectionData state) {
-
- final Stream<ManagedObject> initData = state.streamElements()
- .map(this::recreateReference);
-
- val collectionFacet = collectionSpec.getFacet(CollectionFacet.class);
- return collectionFacet.populatePojo(
- emptyCollectionPojoFactory, collectionSpec, initData, state.getElementCount());
- }
-
- private void updateFieldsAndResolveState(final ManagedObject adapter, final Data data) {
-
- val spec = adapter.getSpecification();
-
- val objectData = (ObjectData) data;
- if (objectData.hasAnyField()) {
-
- // TODO this is an experimental predicate, what's actually needed here?
- if (spec.isValue() || spec.isParentedOrFreeCollection()) {
- throw _Exceptions.unrecoverableFormatted(
- "Resolve state (for %s) inconsistent with fact that data exists for fields",
- spec);
- }
-
- updateFields(adapter, objectData);
- }
-
- }
-
- private void updateFields(final ManagedObject adapter, final ObjectData objectData) {
-
- adapter.getSpecification().streamAssociations(Contributed.EXCLUDED)
- .filter(field->{
- if (field.isNotPersisted()) {
- if (field.isOneToManyAssociation()) {
- return false;
- }
- if (field.containsFacet(PropertyOrCollectionAccessorFacet.class)
- && !field.containsFacet(PropertySetterFacet.class)) {
-
- log.debug("ignoring not-settable field {}", field.getName());
- return false;
- }
- }
- return true;
- })
- .forEach(field->updateField(adapter, objectData, field));
-
- }
-
- private void updateField(
- final ManagedObject adapter,
- final ObjectData objectData,
- final ObjectAssociation objectAssoc) {
-
- final Object fieldData = objectData.getEntry(objectAssoc.getId());
-
- if (objectAssoc.isOneToManyAssociation()) {
- updateOneToManyAssociation(adapter, (OneToManyAssociation) objectAssoc, (CollectionData) fieldData);
-
- } else if (objectAssoc.getSpecification().containsFacet(EncodableFacet.class)) {
- final EncodableFacet facet = objectAssoc.getSpecification().getFacet(EncodableFacet.class);
- final ManagedObject value = facet.fromEncodedString((String) fieldData);
- ((OneToOneAssociation) objectAssoc).initAssociation(adapter, value);
-
- } else if (objectAssoc.isOneToOneAssociation()) {
- updateOneToOneAssociation(adapter, (OneToOneAssociation) objectAssoc, (Data) fieldData);
- }
- }
-
- private void updateOneToManyAssociation(
- ManagedObject objectAdapter,
- OneToManyAssociation otma,
- CollectionData collectionData) {
-
- val collection = otma.get(objectAdapter, InteractionInitiatedBy.FRAMEWORK);
-
- final Set<ManagedObject> original = CollectionFacet.Utils.streamAdapters(collection)
- .collect(Collectors.toCollection(LinkedHashSet::new));
- final Set<ManagedObject> incoming = collectionData.streamElements()
- .map(this::recreateReference)
- .collect(Collectors.toCollection(LinkedHashSet::new));
-
- incoming.stream()
- .filter(original::contains)
- .forEach(elementAdapter->{
- if (log.isDebugEnabled()) {
- log.debug(" association {} changed, added {}", otma, ManagedObject._identify(elementAdapter));
- }
- otma.addElement(objectAdapter, elementAdapter, InteractionInitiatedBy.FRAMEWORK);
- });
-
- original.stream()
- .filter(not(incoming::contains))
- .forEach(elementAdapter->{
- if (log.isDebugEnabled()) {
- log.debug(" association {} changed, removed {}", otma, ManagedObject._identify(elementAdapter));
- }
- otma.removeElement(objectAdapter, elementAdapter, InteractionInitiatedBy.FRAMEWORK);
- });
-
- }
-
- private void updateOneToOneAssociation(
- final ManagedObject objectAdapter,
- final OneToOneAssociation otoa,
- final Data assocData) {
-
- if (assocData == null) {
- otoa.initAssociation(objectAdapter, null);
- } else {
- final ManagedObject ref = recreateReference(assocData);
- if (otoa.get(objectAdapter, InteractionInitiatedBy.FRAMEWORK) != ref) {
- if (log.isDebugEnabled()) {
- log.debug(" association {} changed to {}", otoa, ManagedObject._identify(ref));
- }
- otoa.initAssociation(objectAdapter, ref);
- }
- }
- }
-
- private ManagedObject adapterForOid(RootOid oid) {
- val spec = specificationLoader.loadSpecification(oid.getObjectSpecId());
- val objectLoadRequest = ObjectLoader.Request.of(spec, oid.getIdentifier());
- return objectManager.loadObject(objectLoadRequest);
- }
-
- private ManagedObject adapterForPojo(Object pojo) {
- return objectManager.adapt(pojo);
- }
-
-
-}
diff --git a/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/services/mementos/StandaloneData.java b/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/services/mementos/StandaloneData.java
deleted file mode 100644
index 7ea4343..0000000
--- a/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/services/mementos/StandaloneData.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.wicket.viewer.services.mementos;
-
-import java.io.Serializable;
-import java.util.function.Function;
-
-import org.apache.isis.core.metamodel.adapter.oid.RootOid;
-import org.apache.isis.core.metamodel.facets.object.encodeable.EncodableFacet;
-import org.apache.isis.core.metamodel.spec.ManagedObject;
-import org.apache.isis.core.metamodel.specloader.SpecificationLoader;
-
-import lombok.val;
-
-final class StandaloneData extends Data {
-
- private static final long serialVersionUID = 1L;
-
- private String objectAsEncodedString;
- private Serializable objectAsSerializable;
-
- public StandaloneData(RootOid rootOid, ManagedObject adapter) {
- super(rootOid);
-
- final Object object = adapter.getPojo();
- if (object instanceof Serializable) {
- this.objectAsSerializable = (Serializable) object;
- return;
- }
-
- val encodeableFacet = adapter.getSpecification().getFacet(EncodableFacet.class);
- if (encodeableFacet != null) {
- this.objectAsEncodedString = encodeableFacet.toEncodedString(adapter);
- return;
- }
-
- throw new IllegalArgumentException("Object wrapped by standalone adapter is not serializable and its specificatoin does not have an EncodeableFacet");
- }
-
- public ManagedObject getAdapter(
- Function<Object, ManagedObject> objectAdapterProvider,
- SpecificationLoader specificationLoader) {
-
- if (objectAsSerializable != null) {
- return objectAdapterProvider.apply(objectAsSerializable);
- } else {
- val spec = specificationLoader.lookupBySpecIdElseLoad(getObjectSpecId());
- val encodeableFacet = spec.getFacet(EncodableFacet.class);
- return encodeableFacet.fromEncodedString(objectAsEncodedString);
- }
- }
-
-}