You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2017/11/14 22:45:26 UTC
[isis] 03/03: ISIS-1759: suppresses superfluous calls to obtain
value of property if the property is hidden anyway
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a commit to branch ISIS-1759
in repository https://gitbox.apache.org/repos/asf/isis.git
commit 003f830d53c96d5b4405641bc47b38298868e665
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Tue Nov 14 22:44:53 2017 +0000
ISIS-1759: suppresses superfluous calls to obtain value of property if the property is hidden anyway
---
.../viewer/wicket/model/models/ScalarModel.java | 26 +++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/core/viewer-wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/ScalarModel.java b/core/viewer-wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/ScalarModel.java
index 7feeb06..315c126 100644
--- a/core/viewer-wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/ScalarModel.java
+++ b/core/viewer-wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/ScalarModel.java
@@ -288,10 +288,8 @@ public class ScalarModel extends EntityModel implements LinksProvider,FormExecut
final OneToOneAssociation property = scalarModel.propertyMemento.getProperty(scalarModel.getSpecificationLoader());
final ObjectAdapter parentAdapter = scalarModel.getParentEntityModel().load();
+ setObjectFromPropertyIfVisible(scalarModel, property, parentAdapter);
- final ObjectAdapter associatedAdapter =
- property.get(parentAdapter, InteractionInitiatedBy.USER);
- scalarModel.setObject(associatedAdapter);
}
@Override
@@ -625,6 +623,24 @@ public class ScalarModel extends EntityModel implements LinksProvider,FormExecut
public abstract String toStringOf(final ScalarModel scalarModel);
}
+ private static void setObjectFromPropertyIfVisible(
+ final ScalarModel scalarModel,
+ final OneToOneAssociation property,
+ final ObjectAdapter parentAdapter) {
+
+ // optimisation... no need to sync ScalarModel with property value if not visible anyway
+
+ // TODO: shouldn't assume OBJECT_FORMS ... need to pass in somehow
+ final Consent visibility =
+ property.isVisible(parentAdapter, InteractionInitiatedBy.FRAMEWORK, Where.OBJECT_FORMS);
+
+ final ObjectAdapter associatedAdapter =
+ visibility.isAllowed()
+ ? property.get(parentAdapter, InteractionInitiatedBy.USER)
+ : null;
+
+ scalarModel.setObject(associatedAdapter);
+ }
private final Kind kind;
@@ -696,8 +712,8 @@ public class ScalarModel extends EntityModel implements LinksProvider,FormExecut
final OneToOneAssociation property = propertyMemento.getProperty(getSpecificationLoader());
final ObjectAdapter parentAdapter = parentAdapterMemento.getObjectAdapter(ConcurrencyChecking.CHECK,
getPersistenceSession(), getSpecificationLoader());
- final ObjectAdapter associatedAdapter = property.get(parentAdapter, InteractionInitiatedBy.USER);
- setObject(associatedAdapter);
+
+ setObjectFromPropertyIfVisible(ScalarModel.this, property, parentAdapter);
}
public boolean isCollection() {
--
To stop receiving notification emails like this one, please contact
"commits@isis.apache.org" <co...@isis.apache.org>.