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 2014/07/11 12:56:55 UTC
[43/61] [partial] ISIS-831: digression: moving progmodel/facets into
metamodel/facets
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/fallback/FallbackFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/fallback/FallbackFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/fallback/FallbackFacetFactory.java
new file mode 100644
index 0000000..0c26d5e
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/fallback/FallbackFacetFactory.java
@@ -0,0 +1,158 @@
+/*
+ * 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.core.metamodel.facets.fallback;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.commons.config.IsisConfigurationAware;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facetapi.FacetUtil;
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
+import org.apache.isis.core.metamodel.facets.FacetedMethod;
+import org.apache.isis.core.metamodel.facets.TypedHolder;
+import org.apache.isis.core.metamodel.facets.actions.defaults.fallback.ActionDefaultsFacetNone;
+import org.apache.isis.core.metamodel.facets.all.describedas.fallback.DescribedAsFacetNone;
+import org.apache.isis.core.metamodel.facets.all.help.fallback.HelpFacetNone;
+import org.apache.isis.core.metamodel.facets.all.named.fallback.NamedFacetNone;
+import org.apache.isis.core.metamodel.facets.object.notpersistable.fallback.NotPersistableFacetNull;
+import org.apache.isis.core.metamodel.facets.object.paged.fallback.PagedFacetDefault;
+import org.apache.isis.core.metamodel.facets.object.title.fallback.TitleFacetNone;
+import org.apache.isis.core.metamodel.facets.param.choices.fallback.ActionChoicesFacetNone;
+import org.apache.isis.core.metamodel.facets.propparam.fallback.MaxLengthFacetUnlimited;
+import org.apache.isis.core.metamodel.facets.propparam.fallback.MultiLineFacetNone;
+
+/**
+ * Central point for providing some kind of default for any {@link Facet}s
+ * required by the Apache Isis framework itself.
+ *
+ */
+public class FallbackFacetFactory extends FacetFactoryAbstract implements IsisConfigurationAware {
+
+ public final static int PAGE_SIZE_STANDALONE_DEFAULT = 25;
+ public final static int PAGE_SIZE_PARENTED_DEFAULT = 12;
+
+ private IsisConfiguration configuration;
+
+ @SuppressWarnings("unused")
+ private final static Map<Class<?>, Integer> TYPICAL_LENGTHS_BY_CLASS = new HashMap<Class<?>, Integer>() {
+ private static final long serialVersionUID = 1L;
+ {
+ putTypicalLength(byte.class, Byte.class, 3);
+ putTypicalLength(short.class, Short.class, 5);
+ putTypicalLength(int.class, Integer.class, 10);
+ putTypicalLength(long.class, Long.class, 20);
+ putTypicalLength(float.class, Float.class, 20);
+ putTypicalLength(double.class, Double.class, 20);
+ putTypicalLength(char.class, Character.class, 1);
+ putTypicalLength(boolean.class, Boolean.class, 1);
+ }
+
+ private void putTypicalLength(final Class<?> primitiveClass, final Class<?> wrapperClass, final int length) {
+ put(primitiveClass, Integer.valueOf(length));
+ put(wrapperClass, Integer.valueOf(length));
+ }
+ };
+
+ public FallbackFacetFactory() {
+ super(FeatureType.EVERYTHING);
+ }
+
+ public boolean recognizes(final Method method) {
+ return false;
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContaxt) {
+ final FacetHolder facetHolder = processClassContaxt.getFacetHolder();
+
+ final DescribedAsFacetNone describedAsFacet = new DescribedAsFacetNone(facetHolder);
+ final NotPersistableFacetNull notPersistableFacet = new NotPersistableFacetNull(facetHolder);
+ final TitleFacetNone titleFacet = new TitleFacetNone(facetHolder);
+ final PagedFacetDefault pagedFacet = new PagedFacetDefault(facetHolder, getConfiguration().getInteger("isis.viewers.paged.standalone", PAGE_SIZE_STANDALONE_DEFAULT));
+
+ final Facet[] facets = new Facet[] { describedAsFacet,
+ // commenting these out, think this whole isNoop business is a little bogus
+ // new ImmutableFacetNever(holder),
+ notPersistableFacet, titleFacet, pagedFacet};
+ FacetUtil.addFacets(facets);
+ }
+
+ @Override
+ public void process(final ProcessMethodContext processMethodContext) {
+ final List<Facet> facets = new ArrayList<Facet>();
+
+ final FacetedMethod facetedMethod = processMethodContext.getFacetHolder();
+
+
+ facets.add(new NamedFacetNone(facetedMethod));
+ facets.add(new DescribedAsFacetNone(facetedMethod));
+ facets.add(new HelpFacetNone(facetedMethod));
+
+
+ final FeatureType featureType = facetedMethod.getFeatureType();
+ if (featureType.isProperty()) {
+ facets.add(new MaxLengthFacetUnlimited(facetedMethod));
+ facets.add(new MultiLineFacetNone(true, facetedMethod));
+ }
+ if (featureType.isAction()) {
+ facets.add(new ActionDefaultsFacetNone(facetedMethod));
+ facets.add(new ActionChoicesFacetNone(facetedMethod));
+ }
+ if (featureType.isCollection()) {
+ facets.add(new PagedFacetDefault(facetedMethod, getConfiguration().getInteger("isis.viewers.paged.parented", PAGE_SIZE_PARENTED_DEFAULT)));
+ }
+
+ FacetUtil.addFacets(facets);
+ }
+
+ @Override
+ public void processParams(final ProcessParameterContext processParameterContext) {
+ final List<Facet> facets = new ArrayList<Facet>();
+
+ final TypedHolder typedHolder = processParameterContext.getFacetHolder();
+ if (typedHolder.getFeatureType().isActionParameter()) {
+ facets.add(new NamedFacetNone(typedHolder));
+ facets.add(new DescribedAsFacetNone(typedHolder));
+ facets.add(new HelpFacetNone(typedHolder));
+ facets.add(new MultiLineFacetNone(false, typedHolder));
+
+ facets.add(new MaxLengthFacetUnlimited(typedHolder));
+ }
+
+ FacetUtil.addFacets(facets);
+ }
+
+ @Override
+ public void setConfiguration(IsisConfiguration configuration) {
+ this.configuration = configuration;
+ }
+
+ public IsisConfiguration getConfiguration() {
+ return configuration;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/help/HelpFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/help/HelpFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/help/HelpFacet.java
deleted file mode 100644
index 3eea680..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/help/HelpFacet.java
+++ /dev/null
@@ -1,29 +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.core.metamodel.facets.help;
-
-import org.apache.isis.core.metamodel.facets.SingleStringValueFacet;
-
-/**
- * Provide help about a class, a property, collection or action or a parameter.
- *
- */
-public interface HelpFacet extends SingleStringValueFacet {
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/help/HelpFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/help/HelpFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/help/HelpFacetAbstract.java
deleted file mode 100644
index 381937e..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/help/HelpFacetAbstract.java
+++ /dev/null
@@ -1,36 +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.core.metamodel.facets.help;
-
-import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.SingleStringValueFacetAbstract;
-
-public abstract class HelpFacetAbstract extends SingleStringValueFacetAbstract implements HelpFacet {
-
- public static Class<? extends Facet> type() {
- return HelpFacet.class;
- }
-
- public HelpFacetAbstract(final String value, final FacetHolder holder) {
- super(type(), holder, value);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/hide/HiddenFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/hide/HiddenFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/hide/HiddenFacet.java
deleted file mode 100644
index 2bca352..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/hide/HiddenFacet.java
+++ /dev/null
@@ -1,42 +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.core.metamodel.facets.hide;
-
-import org.apache.isis.applib.annotation.Where;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facets.WhenAndWhereValueFacet;
-import org.apache.isis.core.metamodel.interactions.HidingInteractionAdvisor;
-
-/**
- * Hide a property, collection or action.
- *
- * <p>
- * In the standard Apache Isis Programming Model, corresponds to annotating the
- * member with <tt>@Hidden</tt>.
- */
-public interface HiddenFacet extends WhenAndWhereValueFacet, HidingInteractionAdvisor {
-
- /**
- * The reason why the (feature of the) target object is currently hidden, or
- * <tt>null</tt> if visible.
- */
- public String hiddenReason(ObjectAdapter target, Where whereContext);
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/hide/HiddenObjectFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/hide/HiddenObjectFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/hide/HiddenObjectFacet.java
deleted file mode 100755
index 9dbd0fb..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/hide/HiddenObjectFacet.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.core.metamodel.facets.hide;
-
-import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.interactions.HidingInteractionAdvisor;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.ObjectMember;
-
-/**
- * Mechanism for determining whether this object is should be hidden.
- *
- * <p>
- * Even though all the properties of an object may themselves be visible, there
- * could be reasons to hide the object.
- * </p>
- *
- * <p>
- * In the standard Apache Isis Programming Model, typically corresponds to the
- * <tt>hidden</tt> method.
- * </p>
- *
- * @see HiddenFacet
- */
-public interface HiddenObjectFacet extends Facet, HidingInteractionAdvisor {
-
- /**
- * Clone this facet onto another {@link FacetHolder}.
- *
- * <p>
- * Introduced to allow this facet to be installed onto the
- * {@link ObjectSpecification}, and then copied down onto each of the spec's
- * {@link ObjectMember}s.
- */
- public void copyOnto(FacetHolder holder);
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/mandatory/MandatoryFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/mandatory/MandatoryFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/mandatory/MandatoryFacet.java
deleted file mode 100644
index eac79a3..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/mandatory/MandatoryFacet.java
+++ /dev/null
@@ -1,58 +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.core.metamodel.facets.mandatory;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.MarkerFacet;
-import org.apache.isis.core.metamodel.interactions.ValidatingInteractionAdvisor;
-
-/**
- * Whether a property or a parameter is mandatory (not optional).
- *
- * <p>
- * For a mandatory property, the object cannot be saved/updated without the
- * value being provided. For a mandatory parameter, the action cannot be invoked
- * without the value being provided.
- *
- * <p>
- * In the standard Apache Isis Programming Model, specify mandatory by
- * <i>omitting</i> the <tt>@Optional</tt> annotation.
- */
-public interface MandatoryFacet extends MarkerFacet, ValidatingInteractionAdvisor {
-
- /**
- * Whether this value is required but has not been provided (and is
- * therefore invalid).
- *
- * <p>
- * If the value has been provided, <i>or</i> if the property or parameter is
- * not required, then will return <tt>false</tt>.
- */
- boolean isRequiredButNull(ObjectAdapter adapter);
-
- /**
- * Indicates that the implementation is overridding the usual semantics, in
- * other words that the {@link FacetHolder} to which this {@link Facet} is
- * attached is <i>not</i> mandatory.
- */
- public boolean isInvertedSemantics();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/mandatory/MandatoryFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/mandatory/MandatoryFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/mandatory/MandatoryFacetAbstract.java
deleted file mode 100644
index ed4f07b..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/mandatory/MandatoryFacetAbstract.java
+++ /dev/null
@@ -1,98 +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.core.metamodel.facets.mandatory;
-
-import org.apache.isis.applib.events.ValidityEvent;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.MarkerFacetAbstract;
-import org.apache.isis.core.metamodel.facets.named.NamedFacet;
-import org.apache.isis.core.metamodel.interactions.ActionArgumentContext;
-import org.apache.isis.core.metamodel.interactions.PropertyModifyContext;
-import org.apache.isis.core.metamodel.interactions.ProposedHolder;
-import org.apache.isis.core.metamodel.interactions.ValidityContext;
-import org.apache.isis.core.metamodel.spec.ObjectAdapterUtils;
-
-public abstract class MandatoryFacetAbstract extends MarkerFacetAbstract implements MandatoryFacet {
-
- public static Class<? extends Facet> type() {
- return MandatoryFacet.class;
- }
-
- public enum Semantics {
- REQUIRED,
- OPTIONAL;
-
- public static Semantics of(boolean required) {
- return required ? REQUIRED: OPTIONAL;
- }
- }
-
- private Semantics semantics;
-
- public MandatoryFacetAbstract(final FacetHolder holder, final Semantics semantics) {
- super(type(), holder);
- this.semantics = semantics;
- }
-
- /**
- * If not specified or, if a string, then zero length.
- */
- @Override
- public final boolean isRequiredButNull(final ObjectAdapter adapter) {
- if(!isInvertedSemantics()) {
- final Object object = ObjectAdapter.Util.unwrap(adapter);
- if (object == null) {
- return true;
- }
- // special case string handling.
- final String str = ObjectAdapter.Util.unwrapAsString(adapter);
- return str != null && str.length() == 0;
- } else {
- return false;
- }
- }
-
- @Override
- public boolean isInvertedSemantics() {
- return this.semantics == Semantics.OPTIONAL;
- }
-
- @Override
- public String invalidates(final ValidityContext<? extends ValidityEvent> context) {
- if (!(context instanceof PropertyModifyContext) && !(context instanceof ActionArgumentContext)) {
- return null;
- }
- if (!(context instanceof ProposedHolder)) {
- // shouldn't happen, since both the above should hold a proposed
- // value/argument
- return null;
- }
- final ProposedHolder proposedHolder = (ProposedHolder) context;
- final boolean required = isRequiredButNull(proposedHolder.getProposed());
- if (!required) {
- return null;
- }
- final NamedFacet namedFacet = getFacetHolder().getFacet(NamedFacet.class);
- final String name = namedFacet != null? namedFacet.value(): null;
- return name != null? "'" + name + "' is mandatory":"Mandatory";
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/mandatory/MandatoryFacetDefault.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/mandatory/MandatoryFacetDefault.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/mandatory/MandatoryFacetDefault.java
deleted file mode 100644
index b72eb18..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/mandatory/MandatoryFacetDefault.java
+++ /dev/null
@@ -1,43 +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.core.metamodel.facets.mandatory;
-
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-
-/**
- * Whether a property or a parameter is mandatory (not optional).
- *
- * <p>
- * For a mandatory property, the object cannot be saved/updated without the
- * value being provided. For a mandatory parameter, the action cannot be invoked
- * without the value being provided.
- *
- * <p>
- * In the standard Apache Isis Programming Model, specify mandatory by
- * <i>omitting</i> the <tt>@Optional</tt> annotation.
- */
-public class MandatoryFacetDefault extends MandatoryFacetAbstract {
-
- public MandatoryFacetDefault(final FacetHolder holder) {
- super(holder, Semantics.REQUIRED);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/maxlen/MaxLengthFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/maxlen/MaxLengthFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/maxlen/MaxLengthFacet.java
deleted file mode 100644
index 6954087..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/maxlen/MaxLengthFacet.java
+++ /dev/null
@@ -1,41 +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.core.metamodel.facets.maxlen;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facets.SingleIntValueFacet;
-import org.apache.isis.core.metamodel.interactions.ValidatingInteractionAdvisor;
-
-/**
- * Whether the (string) property or a parameter's length must not exceed a
- * certain length.
- *
- * <p>
- * In the standard Apache Isis Programming Model, corresponds to the
- * <tt>@MaxLength</tt> annotation.
- */
-public interface MaxLengthFacet extends SingleIntValueFacet, ValidatingInteractionAdvisor {
-
- /**
- * Whether the provided string exceeds the maximum length.
- */
- public boolean exceeds(ObjectAdapter adapter);
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/maxlen/MaxLengthFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/maxlen/MaxLengthFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/maxlen/MaxLengthFacetAbstract.java
deleted file mode 100644
index 39fdc64..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/maxlen/MaxLengthFacetAbstract.java
+++ /dev/null
@@ -1,74 +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.core.metamodel.facets.maxlen;
-
-import org.apache.isis.applib.events.ValidityEvent;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.SingleIntValueFacetAbstract;
-import org.apache.isis.core.metamodel.interactions.ProposedHolder;
-import org.apache.isis.core.metamodel.interactions.ValidityContext;
-import org.apache.isis.core.metamodel.spec.ObjectAdapterUtils;
-
-public abstract class MaxLengthFacetAbstract extends SingleIntValueFacetAbstract implements MaxLengthFacet {
-
- public static Class<? extends Facet> type() {
- return MaxLengthFacet.class;
- }
-
- public MaxLengthFacetAbstract(final int value, final FacetHolder holder) {
- super(type(), holder, value);
- }
-
- /**
- * Whether the provided argument exceeds the {@link #value() maximum length}
- * .
- */
- @Override
- public boolean exceeds(final ObjectAdapter adapter) {
- final String str = ObjectAdapterUtils.unwrapObjectAsString(adapter);
- if (str == null) {
- return false;
- }
- final int maxLength = value();
- return maxLength != 0 && str.length() > maxLength;
- }
-
- @Override
- public String invalidates(final ValidityContext<? extends ValidityEvent> context) {
- if (!(context instanceof ProposedHolder)) {
- return null;
- }
- final ProposedHolder proposedHolder = (ProposedHolder) context;
- final ObjectAdapter proposedArgument = proposedHolder.getProposed();
- if (!exceeds(proposedArgument)) {
- return null;
- }
- return "The value proposed exceeds the maximum length of " + value();
- }
-
- @Override
- protected String toStringValues() {
- final int val = value();
- return val == 0 ? "unlimited" : String.valueOf(val);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/cssclass/annotprop/CssClassFacetOnMemberAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/cssclass/annotprop/CssClassFacetOnMemberAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/cssclass/annotprop/CssClassFacetOnMemberAnnotation.java
new file mode 100644
index 0000000..946cf7e
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/cssclass/annotprop/CssClassFacetOnMemberAnnotation.java
@@ -0,0 +1,30 @@
+/*
+ * 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.core.metamodel.facets.members.cssclass.annotprop;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.members.cssclass.CssClassFacetAbstract;
+
+public class CssClassFacetOnMemberAnnotation extends CssClassFacetAbstract {
+
+ public CssClassFacetOnMemberAnnotation(final String value, final FacetHolder holder) {
+ super(value, holder);
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/cssclass/annotprop/CssClassFacetOnMemberFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/cssclass/annotprop/CssClassFacetOnMemberFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/cssclass/annotprop/CssClassFacetOnMemberFactory.java
new file mode 100644
index 0000000..b645220
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/cssclass/annotprop/CssClassFacetOnMemberFactory.java
@@ -0,0 +1,73 @@
+/*
+ * 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.core.metamodel.facets.members.cssclass.annotprop;
+
+import java.util.Properties;
+
+import org.apache.isis.applib.annotation.CssClass;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facetapi.FacetUtil;
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.Annotations;
+import org.apache.isis.core.metamodel.facets.ContributeeMemberFacetFactory;
+import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
+import org.apache.isis.core.metamodel.facets.members.cssclass.CssClassFacet;
+
+public class CssClassFacetOnMemberFactory extends FacetFactoryAbstract implements ContributeeMemberFacetFactory {
+
+ public CssClassFacetOnMemberFactory() {
+ super(FeatureType.MEMBERS);
+ }
+
+ @Override
+ public void process(final ProcessMethodContext processMethodContext) {
+ CssClassFacet cssClassFacet = createFromMetadataPropertiesIfPossible(processMethodContext);
+ if(cssClassFacet == null) {
+ cssClassFacet = createFromAnnotationIfPossible(processMethodContext);
+ }
+
+ // no-op if null
+ FacetUtil.addFacet(cssClassFacet);
+ }
+
+
+ @Override
+ public void process(ProcessContributeeMemberContext processMemberContext) {
+ CssClassFacet cssClassFacet = createFromMetadataPropertiesIfPossible(processMemberContext);
+ // no-op if null
+ FacetUtil.addFacet(cssClassFacet);
+ }
+
+ private static CssClassFacet createFromMetadataPropertiesIfPossible(
+ final ProcessContextWithMetadataProperties<? extends FacetHolder> pcwmp) {
+
+ final FacetHolder holder = pcwmp.getFacetHolder();
+
+ final Properties properties = pcwmp.metadataProperties("cssClass");
+ return properties != null ? new CssClassFacetOnMemberFromProperties(properties, holder) : null;
+ }
+
+ private CssClassFacet createFromAnnotationIfPossible(final ProcessMethodContext processMethodContext) {
+ final CssClass annotation = Annotations.getAnnotation(processMethodContext.getMethod(), CssClass.class);
+ return annotation != null ? new CssClassFacetOnMemberAnnotation(annotation.value(), processMethodContext.getFacetHolder()) : null;
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/cssclass/annotprop/CssClassFacetOnMemberFromProperties.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/cssclass/annotprop/CssClassFacetOnMemberFromProperties.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/cssclass/annotprop/CssClassFacetOnMemberFromProperties.java
new file mode 100644
index 0000000..04e1d97
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/cssclass/annotprop/CssClassFacetOnMemberFromProperties.java
@@ -0,0 +1,36 @@
+/*
+ * 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.core.metamodel.facets.members.cssclass.annotprop;
+
+import java.util.Properties;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.members.cssclass.CssClassFacetAbstract;
+
+public class CssClassFacetOnMemberFromProperties extends CssClassFacetAbstract {
+
+ public CssClassFacetOnMemberFromProperties(final Properties properties, final FacetHolder holder) {
+ super(valueFrom(properties), holder);
+ }
+
+ private static String valueFrom(Properties properties) {
+ return properties.getProperty("value");
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/describedas/annotprop/DescribedAsFacetOnMemberAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/describedas/annotprop/DescribedAsFacetOnMemberAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/describedas/annotprop/DescribedAsFacetOnMemberAnnotation.java
new file mode 100644
index 0000000..d675c74
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/describedas/annotprop/DescribedAsFacetOnMemberAnnotation.java
@@ -0,0 +1,31 @@
+/*
+ * 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.core.metamodel.facets.members.describedas.annotprop;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.all.describedas.DescribedAsFacetAbstract;
+
+public class DescribedAsFacetOnMemberAnnotation extends DescribedAsFacetAbstract {
+
+ public DescribedAsFacetOnMemberAnnotation(final String value, final FacetHolder holder) {
+ super(value, holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/describedas/annotprop/DescribedAsFacetOnMemberDerivedFromType.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/describedas/annotprop/DescribedAsFacetOnMemberDerivedFromType.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/describedas/annotprop/DescribedAsFacetOnMemberDerivedFromType.java
new file mode 100644
index 0000000..69c09ba
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/describedas/annotprop/DescribedAsFacetOnMemberDerivedFromType.java
@@ -0,0 +1,32 @@
+/*
+ * 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.core.metamodel.facets.members.describedas.annotprop;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.all.describedas.DescribedAsFacet;
+import org.apache.isis.core.metamodel.facets.all.describedas.DescribedAsFacetAbstract;
+
+public class DescribedAsFacetOnMemberDerivedFromType extends DescribedAsFacetAbstract {
+
+ public DescribedAsFacetOnMemberDerivedFromType(final DescribedAsFacet describedAsFacet, final FacetHolder holder) {
+ super(describedAsFacet.value(), holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/describedas/annotprop/DescribedAsFacetOnMemberFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/describedas/annotprop/DescribedAsFacetOnMemberFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/describedas/annotprop/DescribedAsFacetOnMemberFactory.java
new file mode 100644
index 0000000..03e0c3b
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/describedas/annotprop/DescribedAsFacetOnMemberFactory.java
@@ -0,0 +1,88 @@
+/*
+ * 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.core.metamodel.facets.members.describedas.annotprop;
+
+import java.util.Properties;
+
+import org.apache.isis.applib.annotation.DescribedAs;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facetapi.FacetUtil;
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.Annotations;
+import org.apache.isis.core.metamodel.facets.ContributeeMemberFacetFactory;
+import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
+import org.apache.isis.core.metamodel.facets.all.describedas.DescribedAsFacet;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+
+public class DescribedAsFacetOnMemberFactory extends FacetFactoryAbstract implements ContributeeMemberFacetFactory {
+
+ public DescribedAsFacetOnMemberFactory() {
+ super(FeatureType.MEMBERS);
+ }
+
+ @Override
+ public void process(final ProcessMethodContext processMethodContext) {
+
+ DescribedAsFacet facet = createFromMetadataPropertiesIfPossible(processMethodContext);
+
+ if(facet == null) {
+ facet = createFromAnnotationIfPossible(processMethodContext);
+ }
+ if (facet == null) {
+ facet = createFromAnnotationOnReturnTypeIfPossible(processMethodContext);
+ }
+
+ // no-op if null
+ FacetUtil.addFacet(facet);
+ }
+
+ @Override
+ public void process(ProcessContributeeMemberContext processMemberContext) {
+ DescribedAsFacet facet = createFromMetadataPropertiesIfPossible(processMemberContext);
+ // no-op if null
+ FacetUtil.addFacet(facet);
+ }
+
+ private static DescribedAsFacet createFromMetadataPropertiesIfPossible(
+ final ProcessContextWithMetadataProperties<? extends FacetHolder> pcwmp) {
+
+ final FacetHolder holder = pcwmp.getFacetHolder();
+
+ final Properties properties = pcwmp.metadataProperties("describedAs");
+ return properties != null ? new DescribedAsFacetOnMemberFromProperties(properties, holder) : null;
+ }
+
+ private static DescribedAsFacet createFromAnnotationIfPossible(final ProcessMethodContext processMethodContext) {
+ // look for annotation on the property
+ final DescribedAs annotation = Annotations.getAnnotation(processMethodContext.getMethod(), DescribedAs.class);
+ return annotation == null ? null : new DescribedAsFacetOnMemberAnnotation(annotation.value(), processMethodContext.getFacetHolder());
+ }
+
+ private DescribedAsFacet createFromAnnotationOnReturnTypeIfPossible(final ProcessMethodContext processMethodContext) {
+ final Class<?> returnType = processMethodContext.getMethod().getReturnType();
+ final DescribedAsFacet returnTypeDescribedAsFacet = getDescribedAsFacet(returnType);
+ return returnTypeDescribedAsFacet != null ? new DescribedAsFacetOnMemberDerivedFromType(returnTypeDescribedAsFacet, processMethodContext.getFacetHolder()) : null;
+ }
+
+ private DescribedAsFacet getDescribedAsFacet(final Class<?> type) {
+ final ObjectSpecification paramTypeSpec = getSpecificationLoader().loadSpecification(type);
+ return paramTypeSpec.getFacet(DescribedAsFacet.class);
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/describedas/annotprop/DescribedAsFacetOnMemberFromProperties.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/describedas/annotprop/DescribedAsFacetOnMemberFromProperties.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/describedas/annotprop/DescribedAsFacetOnMemberFromProperties.java
new file mode 100644
index 0000000..08a1318
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/describedas/annotprop/DescribedAsFacetOnMemberFromProperties.java
@@ -0,0 +1,37 @@
+/*
+ * 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.core.metamodel.facets.members.describedas.annotprop;
+
+import java.util.Properties;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.all.describedas.DescribedAsFacetAbstract;
+
+public class DescribedAsFacetOnMemberFromProperties extends DescribedAsFacetAbstract {
+
+ public DescribedAsFacetOnMemberFromProperties(final Properties properties, final FacetHolder holder) {
+ super(valueFrom(properties), holder);
+ }
+
+ private static String valueFrom(final Properties properties) {
+ return properties.getProperty("value");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/describedas/staticmethod/DescribedAsFacetStaticMethod.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/describedas/staticmethod/DescribedAsFacetStaticMethod.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/describedas/staticmethod/DescribedAsFacetStaticMethod.java
new file mode 100644
index 0000000..afd5c48
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/describedas/staticmethod/DescribedAsFacetStaticMethod.java
@@ -0,0 +1,59 @@
+/*
+ * 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.core.metamodel.facets.members.describedas.staticmethod;
+
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.ImperativeFacet;
+import org.apache.isis.core.metamodel.facets.all.describedas.DescribedAsFacetAbstract;
+
+public class DescribedAsFacetStaticMethod extends DescribedAsFacetAbstract implements ImperativeFacet {
+
+ private final Method method;
+
+ public DescribedAsFacetStaticMethod(final String value, final Method method, final FacetHolder holder) {
+ super(value, holder);
+ this.method = method;
+ }
+
+ @Override
+ public List<Method> getMethods() {
+ return Collections.singletonList(method);
+ }
+
+ @Override
+ public Intent getIntent(final Method method) {
+ return Intent.UI_HINT;
+ }
+
+ @Override
+ public boolean impliesResolve() {
+ return false;
+ }
+
+ @Override
+ public boolean impliesObjectChanged() {
+ return false;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/describedas/staticmethod/DescribedAsFacetStaticMethodFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/describedas/staticmethod/DescribedAsFacetStaticMethodFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/describedas/staticmethod/DescribedAsFacetStaticMethodFactory.java
new file mode 100644
index 0000000..b96fbe9
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/describedas/staticmethod/DescribedAsFacetStaticMethodFactory.java
@@ -0,0 +1,93 @@
+/*
+ * 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.core.metamodel.facets.members.describedas.staticmethod;
+
+import java.lang.reflect.Method;
+
+import org.apache.isis.core.commons.lang.MethodExtensions;
+import org.apache.isis.core.commons.lang.StringExtensions;
+import org.apache.isis.core.metamodel.exceptions.MetaModelException;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facetapi.FacetUtil;
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.all.describedas.DescribedAsFacet;
+import org.apache.isis.core.metamodel.methodutils.MethodScope;
+import org.apache.isis.core.metamodel.facets.MethodFinderUtils;
+import org.apache.isis.core.metamodel.facets.MethodPrefixBasedFacetFactoryAbstract;
+import org.apache.isis.core.metamodel.facets.MethodPrefixConstants;
+
+/**
+ * Sets up a {@link DescribedAsFacet} if a
+ * {@value MethodPrefixConstants#DESCRIPTION_PREFIX}-prefixed method is present.
+ */
+public class DescribedAsFacetStaticMethodFactory extends MethodPrefixBasedFacetFactoryAbstract {
+
+ private static final String[] PREFIXES = { MethodPrefixConstants.DESCRIPTION_PREFIX };
+
+ /**
+ * Note that the {@link Facet}s registered are the generic ones from
+ * noa-architecture (where they exist)
+ */
+ public DescribedAsFacetStaticMethodFactory() {
+ super(FeatureType.MEMBERS, OrphanValidation.VALIDATE, PREFIXES);
+ }
+
+ // ///////////////////////////////////////////////////////
+ // Actions
+ // ///////////////////////////////////////////////////////
+
+ @Override
+ public void process(final ProcessMethodContext processMethodContext) {
+ attachDescribedAsFacetIfDescriptionMethodIsFound(processMethodContext);
+ }
+
+ public static void attachDescribedAsFacetIfDescriptionMethodIsFound(final ProcessMethodContext processMethodContext) {
+
+ final Method method = processMethodContext.getMethod();
+ final String capitalizedName = StringExtensions.asJavaBaseNameStripAccessorPrefixIfRequired(method.getName());
+
+ final Class<?> cls = processMethodContext.getCls();
+ final Method descriptionMethod = MethodFinderUtils.findMethod(cls, MethodScope.CLASS, MethodPrefixConstants.DESCRIPTION_PREFIX + capitalizedName, String.class, new Class[0]);
+ if (descriptionMethod == null) {
+ return;
+ }
+
+ processMethodContext.removeMethod(descriptionMethod);
+ final String description = invokeDescriptionMethod(descriptionMethod);
+
+ final FacetHolder facetedMethod = processMethodContext.getFacetHolder();
+ FacetUtil.addFacet(new DescribedAsFacetStaticMethod(description, descriptionMethod, facetedMethod));
+ }
+
+ private static String invokeDescriptionMethod(final Method descriptionMethod) {
+ String description = null;
+ try {
+ description = (String) MethodExtensions.invokeStatic(descriptionMethod);
+ } catch (final ClassCastException ex) {
+ // ignore
+ }
+ if (description == null) {
+ throw new MetaModelException("method " + descriptionMethod + "must return a string");
+ }
+ return description;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/DisabledFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/DisabledFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/DisabledFacet.java
new file mode 100644
index 0000000..be97e7f
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/DisabledFacet.java
@@ -0,0 +1,40 @@
+/*
+ * 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.core.metamodel.facets.members.disabled;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.WhenAndWhereValueFacet;
+import org.apache.isis.core.metamodel.interactions.DisablingInteractionAdvisor;
+
+/**
+ * Disable a property, collection or action.
+ *
+ * <p>
+ * In the standard Apache Isis Programming Model, corresponds to annotating the
+ * member with <tt>@Disabled</tt>.
+ */
+public interface DisabledFacet extends WhenAndWhereValueFacet, DisablingInteractionAdvisor {
+
+ /**
+ * The reason why the (feature of the) target object is currently disabled,
+ * or <tt>null</tt> if enabled.
+ */
+ public String disabledReason(ObjectAdapter target);
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/DisabledFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/DisabledFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/DisabledFacetAbstract.java
new file mode 100644
index 0000000..c2f9d69
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/DisabledFacetAbstract.java
@@ -0,0 +1,55 @@
+/*
+ * 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.core.metamodel.facets.members.disabled;
+
+import org.apache.isis.applib.annotation.When;
+import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.applib.events.UsabilityEvent;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.WhenAndWhereValueFacetAbstract;
+import org.apache.isis.core.metamodel.interactions.UsabilityContext;
+
+public abstract class DisabledFacetAbstract extends WhenAndWhereValueFacetAbstract implements DisabledFacet {
+
+ public static Class<? extends Facet> type() {
+ return DisabledFacet.class;
+ }
+
+ public DisabledFacetAbstract(final When when, Where where, final FacetHolder holder) {
+ super(type(), holder, when, where);
+ }
+
+ @Override
+ public String disables(final UsabilityContext<? extends UsabilityEvent> ic) {
+ final ObjectAdapter target = ic.getTarget();
+ final String disabledReason = disabledReason(target);
+ if (disabledReason != null) {
+ return disabledReason;
+ }
+ if (getUnderlyingFacet() != null) {
+ final DisabledFacet underlyingFacet = (DisabledFacet) getUnderlyingFacet();
+ return underlyingFacet.disabledReason(target);
+ }
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/DisabledFacetAlwaysEverywhere.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/DisabledFacetAlwaysEverywhere.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/DisabledFacetAlwaysEverywhere.java
new file mode 100644
index 0000000..8831068
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/DisabledFacetAlwaysEverywhere.java
@@ -0,0 +1,41 @@
+/*
+ * 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.core.metamodel.facets.members.disabled;
+
+import org.apache.isis.applib.annotation.When;
+import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+
+public class DisabledFacetAlwaysEverywhere extends DisabledFacetAbstract {
+
+ public DisabledFacetAlwaysEverywhere(final FacetHolder holder) {
+ super(When.ALWAYS, Where.ANYWHERE, holder);
+ }
+
+ /**
+ * Always returns <i>Always disabled</i>.
+ */
+ @Override
+ public String disabledReason(final ObjectAdapter target) {
+ return "Always disabled";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/DisabledFacetImpl.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/DisabledFacetImpl.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/DisabledFacetImpl.java
new file mode 100644
index 0000000..070956e
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/DisabledFacetImpl.java
@@ -0,0 +1,74 @@
+/*
+ * 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.core.metamodel.facets.members.disabled;
+
+import com.google.common.base.Strings;
+
+import org.apache.isis.applib.annotation.When;
+import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+
+public class DisabledFacetImpl extends DisabledFacetAbstract {
+
+ private final String reason;
+
+ public DisabledFacetImpl(final When when, final Where where, final FacetHolder holder) {
+ this(when, where, null, holder);
+ }
+
+ public DisabledFacetImpl(final When when, final Where where, final String reason, final FacetHolder holder) {
+ super(when, where, holder);
+ this.reason = reason;
+ }
+
+ @Override
+ public String disabledReason(final ObjectAdapter targetAdapter) {
+ if (when() == When.ALWAYS) {
+ return disabledReasonElse("Always disabled");
+ } else if (when() == When.NEVER) {
+ return null;
+ }
+
+ // remaining tests depend upon the actual target in question
+ if (targetAdapter == null) {
+ return null;
+ }
+
+ if (when() == When.UNTIL_PERSISTED) {
+ return targetAdapter.isTransient() ? disabledReasonElse("Disabled until persisted") : null;
+ } else if (when() == When.ONCE_PERSISTED) {
+ return targetAdapter.representsPersistent() ? disabledReasonElse("Disabled once persisted") : null;
+ }
+ return null;
+ }
+
+ private String disabledReasonElse(final String defaultReason) {
+ return !Strings.isNullOrEmpty(reason) ? reason : defaultReason;
+ }
+
+ /**
+ * Not API... the reason as defined in subclass
+ */
+ public String getReason() {
+ return reason;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/DisabledFacetNever.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/DisabledFacetNever.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/DisabledFacetNever.java
new file mode 100644
index 0000000..c3e359c
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/DisabledFacetNever.java
@@ -0,0 +1,46 @@
+/*
+ * 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.core.metamodel.facets.members.disabled;
+
+import org.apache.isis.applib.annotation.When;
+import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+
+public class DisabledFacetNever extends DisabledFacetAbstract {
+
+ public DisabledFacetNever(final FacetHolder holder) {
+ super(When.NEVER, Where.ANYWHERE, holder);
+ }
+
+ /**
+ * Always returns <tt>null</tt>.
+ */
+ @Override
+ public String disabledReason(final ObjectAdapter target) {
+ return null;
+ }
+
+ @Override
+ public boolean isNoop() {
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/annotprop/DisabledFacetAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/annotprop/DisabledFacetAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/annotprop/DisabledFacetAnnotation.java
new file mode 100644
index 0000000..0a855fd
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/annotprop/DisabledFacetAnnotation.java
@@ -0,0 +1,33 @@
+/*
+ * 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.core.metamodel.facets.members.disabled.annotprop;
+
+import org.apache.isis.applib.annotation.When;
+import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.members.disabled.DisabledFacetImpl;
+
+public class DisabledFacetAnnotation extends DisabledFacetImpl {
+
+ public DisabledFacetAnnotation(final When when, Where where, String reason, final FacetHolder holder) {
+ super(when, where, reason, holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/annotprop/DisabledFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/annotprop/DisabledFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/annotprop/DisabledFacetFactory.java
new file mode 100644
index 0000000..e53f174
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/annotprop/DisabledFacetFactory.java
@@ -0,0 +1,74 @@
+/*
+ * 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.core.metamodel.facets.members.disabled.annotprop;
+
+import java.util.Properties;
+
+import org.apache.isis.applib.annotation.Disabled;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facetapi.FacetUtil;
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.Annotations;
+import org.apache.isis.core.metamodel.facets.ContributeeMemberFacetFactory;
+import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
+import org.apache.isis.core.metamodel.facets.members.disabled.DisabledFacet;
+
+public class DisabledFacetFactory extends FacetFactoryAbstract
+ implements ContributeeMemberFacetFactory {
+
+ public DisabledFacetFactory() {
+ super(FeatureType.MEMBERS);
+ }
+
+ @Override
+ public void process(final ProcessMethodContext processMethodContext) {
+ DisabledFacet disabledFacet = createFromMetadataPropertiesIfPossible(processMethodContext);
+ if(disabledFacet == null) {
+ disabledFacet = createFromAnnotationIfPossible(processMethodContext);
+ }
+ // no-op if null
+ FacetUtil.addFacet(disabledFacet);
+ }
+
+ @Override
+ public void process(ProcessContributeeMemberContext processMemberContext) {
+ DisabledFacet disabledFacet = createFromMetadataPropertiesIfPossible(processMemberContext);
+ // no-op if null
+ FacetUtil.addFacet(disabledFacet);
+ }
+
+ private static DisabledFacet createFromAnnotationIfPossible(final ProcessMethodContext processMethodContext) {
+ final Disabled annotation = Annotations.getAnnotation(processMethodContext.getMethod(), Disabled.class);
+ return annotation != null
+ ? new DisabledFacetAnnotation(annotation.when(), annotation.where(), annotation.reason(), processMethodContext.getFacetHolder())
+ : null;
+ }
+
+ private static DisabledFacet createFromMetadataPropertiesIfPossible(
+ final ProcessContextWithMetadataProperties<? extends FacetHolder> pcwmp) {
+
+ final FacetHolder holder = pcwmp.getFacetHolder();
+
+ final Properties properties = pcwmp.metadataProperties("disabled");
+ return properties != null ? new DisabledFacetFromProperties(properties, holder) : null;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/annotprop/DisabledFacetFromProperties.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/annotprop/DisabledFacetFromProperties.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/annotprop/DisabledFacetFromProperties.java
new file mode 100644
index 0000000..89002d6
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/annotprop/DisabledFacetFromProperties.java
@@ -0,0 +1,57 @@
+/*
+ * 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.core.metamodel.facets.members.disabled.annotprop;
+
+import java.util.Properties;
+
+import org.apache.isis.applib.annotation.When;
+import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.members.disabled.DisabledFacetImpl;
+
+public class DisabledFacetFromProperties extends DisabledFacetImpl {
+
+ public DisabledFacetFromProperties(final When when, Where where, String reason, final FacetHolder holder) {
+ super(when, where, reason, holder);
+ }
+
+ public DisabledFacetFromProperties(Properties properties, FacetHolder holder) {
+ super(disabledWhenFrom(properties), disabledWhereFrom(properties), disabledReasonFrom(properties), holder);
+ }
+
+ private static When disabledWhenFrom(Properties properties) {
+ String value = properties.getProperty("when");
+ // same default as in Disabled.when()
+ return value != null? When.valueOf(value): When.ALWAYS;
+ }
+
+ private static Where disabledWhereFrom(Properties properties) {
+ String value = properties.getProperty("where");
+ // same default as in Disabled.where()
+ return value != null? Where.valueOf(value): Where.ANYWHERE;
+ }
+
+ private static String disabledReasonFrom(Properties properties) {
+ String value = properties.getProperty("reason");
+ // same default as in Disabled.reason()
+ return value != null? value: "";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/forsession/DisableForSessionFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/forsession/DisableForSessionFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/forsession/DisableForSessionFacet.java
new file mode 100644
index 0000000..4678401
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/forsession/DisableForSessionFacet.java
@@ -0,0 +1,40 @@
+/*
+ * 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.core.metamodel.facets.members.disabled.forsession;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.interactions.DisablingInteractionAdvisor;
+
+/**
+ * Disable a property, collection or action based on the current session.
+ *
+ * <p>
+ * In the standard Apache Isis Programming Model, corresponds to invoking the
+ * <tt>disableXxx(UserMemento)</tt> support method for the member.
+ */
+public interface DisableForSessionFacet extends Facet, DisablingInteractionAdvisor {
+
+ /**
+ * The reason this is disabled, or <tt>null</tt> if not.
+ */
+ public String disabledReason(AuthenticationSession session);
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/forsession/DisableForSessionFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/forsession/DisableForSessionFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/forsession/DisableForSessionFacetAbstract.java
new file mode 100644
index 0000000..67f9c29
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/forsession/DisableForSessionFacetAbstract.java
@@ -0,0 +1,45 @@
+/*
+ * 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.core.metamodel.facets.members.disabled.forsession;
+
+import org.apache.isis.applib.events.UsabilityEvent;
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetAbstract;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.interactions.UsabilityContext;
+
+public abstract class DisableForSessionFacetAbstract extends FacetAbstract implements DisableForSessionFacet {
+
+ public static Class<? extends Facet> type() {
+ return DisableForSessionFacet.class;
+ }
+
+ public DisableForSessionFacetAbstract(final FacetHolder holder) {
+ super(type(), holder, Derivation.NOT_DERIVED);
+ }
+
+ @Override
+ public String disables(final UsabilityContext<? extends UsabilityEvent> ic) {
+ final AuthenticationSession session = ic.getSession();
+ return disabledReason(session);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/forsession/DisableForSessionFacetNone.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/forsession/DisableForSessionFacetNone.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/forsession/DisableForSessionFacetNone.java
new file mode 100644
index 0000000..9178ea8
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/forsession/DisableForSessionFacetNone.java
@@ -0,0 +1,41 @@
+/*
+ * 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.core.metamodel.facets.members.disabled.forsession;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+
+public class DisableForSessionFacetNone extends DisableForSessionFacetAbstract {
+
+ public DisableForSessionFacetNone(final FacetHolder holder) {
+ super(holder);
+ }
+
+ @Override
+ public String disabledReason(final AuthenticationSession session) {
+ return null;
+ }
+
+ @Override
+ public boolean isNoop() {
+ return true;
+ }
+
+}