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/12/29 19:01:34 UTC
[1/3] isis git commit: ISIS-970: facet factory for @Property
annotation.
Repository: isis
Updated Branches:
refs/heads/ISIS-970 93a81dba2 -> c0da099a5
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/TypicalLengthFacetOnPropertyFromLayoutProperties.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/TypicalLengthFacetOnPropertyFromLayoutProperties.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/TypicalLengthFacetOnPropertyFromLayoutProperties.java
new file mode 100644
index 0000000..b3cad29
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/TypicalLengthFacetOnPropertyFromLayoutProperties.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.properties.propertylayout;
+
+import java.util.Properties;
+import com.google.common.base.Strings;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.objpropparam.typicallen.TypicalLengthFacet;
+import org.apache.isis.core.metamodel.facets.objpropparam.typicallen.TypicalLengthFacetAbstract;
+
+public class TypicalLengthFacetOnPropertyFromLayoutProperties extends TypicalLengthFacetAbstract {
+
+ private final int typicalLength;
+
+ public static TypicalLengthFacet create(Properties properties, FacetHolder holder) {
+ final int typicalLength = typicalLength(properties);
+ return typicalLength != -1? new TypicalLengthFacetOnPropertyFromLayoutProperties(typicalLength, holder): null;
+ }
+
+ private TypicalLengthFacetOnPropertyFromLayoutProperties(int typicalLength, FacetHolder holder) {
+ super(holder, Derivation.NOT_DERIVED);
+ this.typicalLength = typicalLength;
+ }
+
+ private static int typicalLength(Properties properties) {
+ if(properties == null) {
+ return -1;
+ }
+ String typicalLength = Strings.emptyToNull(properties.getProperty("typicalLength"));
+ if(typicalLength == null) {
+ return -1;
+ }
+ return Integer.parseInt(typicalLength);
+ }
+
+ @Override
+ public int value() {
+ return typicalLength;
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/validating/mustsatisfyspec/MustSatisfySpecificationFacetForMustSatisfyAnnotationOnProperty.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/validating/mustsatisfyspec/MustSatisfySpecificationFacetForMustSatisfyAnnotationOnProperty.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/validating/mustsatisfyspec/MustSatisfySpecificationFacetForMustSatisfyAnnotationOnProperty.java
new file mode 100644
index 0000000..d559a4e
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/validating/mustsatisfyspec/MustSatisfySpecificationFacetForMustSatisfyAnnotationOnProperty.java
@@ -0,0 +1,52 @@
+/*
+ * 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.properties.validating.mustsatisfyspec;
+
+import java.util.List;
+import com.google.common.collect.Lists;
+import org.apache.isis.applib.annotation.MustSatisfy;
+import org.apache.isis.applib.spec.Specification;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.propparam.mustsatisfyspec.MustSatisfySpecificationFacetAbstract;
+
+public class MustSatisfySpecificationFacetForMustSatisfyAnnotationOnProperty extends MustSatisfySpecificationFacetAbstract {
+
+ static Facet create(final MustSatisfy annotation, final FacetHolder holder) {
+ if (annotation == null) {
+ return null;
+ }
+ final Class<?>[] values = annotation.value();
+ final List<Specification> specifications = Lists.newArrayList();
+ for (final Class<?> value : values) {
+ final Specification specification = newSpecificationElseNull(value);
+ if (specification != null) {
+ specifications.add(specification);
+ }
+ }
+ return specifications.size() > 0 ? new MustSatisfySpecificationFacetForMustSatisfyAnnotationOnProperty(specifications, holder) : null;
+ }
+
+
+ private MustSatisfySpecificationFacetForMustSatisfyAnnotationOnProperty(final List<Specification> specifications, final FacetHolder holder) {
+ super(specifications, holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/validating/mustsatisfyspec/MustSatisfySpecificationOnPropertyFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/validating/mustsatisfyspec/MustSatisfySpecificationOnPropertyFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/validating/mustsatisfyspec/MustSatisfySpecificationOnPropertyFacet.java
deleted file mode 100644
index d8626c6..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/validating/mustsatisfyspec/MustSatisfySpecificationOnPropertyFacet.java
+++ /dev/null
@@ -1,63 +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.properties.validating.mustsatisfyspec;
-
-import java.util.List;
-
-import org.apache.isis.applib.events.ValidityEvent;
-import org.apache.isis.applib.spec.Specification;
-import org.apache.isis.applib.util.ReasonBuffer;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-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.ProposedHolder;
-import org.apache.isis.core.metamodel.interactions.ValidatingInteractionAdvisor;
-import org.apache.isis.core.metamodel.interactions.ValidityContext;
-
-public class MustSatisfySpecificationOnPropertyFacet extends FacetAbstract implements ValidatingInteractionAdvisor {
-
- public static Class<? extends Facet> type() {
- return MustSatisfySpecificationOnPropertyFacet.class;
- }
-
- private final List<Specification> specifications;
-
- public MustSatisfySpecificationOnPropertyFacet(final List<Specification> specifications, final FacetHolder holder) {
- super(type(), holder, Derivation.NOT_DERIVED);
- this.specifications = specifications;
- }
-
- @Override
- public String invalidates(final ValidityContext<? extends ValidityEvent> validityContext) {
- if (!(validityContext instanceof ProposedHolder)) {
- return null;
- }
- final ProposedHolder proposedHolder = (ProposedHolder) validityContext;
- final ObjectAdapter targetNO = proposedHolder.getProposed();
- final Object targetObject = targetNO.getObject();
- final ReasonBuffer buf = new ReasonBuffer();
- for (final Specification specification : specifications) {
- buf.append(specification.satisfies(targetObject));
- }
- return buf.getReason();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/validating/mustsatisfyspec/MustSatisfySpecificationOnPropertyFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/validating/mustsatisfyspec/MustSatisfySpecificationOnPropertyFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/validating/mustsatisfyspec/MustSatisfySpecificationOnPropertyFacetFactory.java
index 3dfa6ad..d63045f 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/validating/mustsatisfyspec/MustSatisfySpecificationOnPropertyFacetFactory.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/validating/mustsatisfyspec/MustSatisfySpecificationOnPropertyFacetFactory.java
@@ -20,11 +20,8 @@
package org.apache.isis.core.metamodel.facets.properties.validating.mustsatisfyspec;
import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
import org.apache.isis.applib.annotation.MustSatisfy;
-import org.apache.isis.applib.spec.Specification;
import org.apache.isis.core.metamodel.facetapi.Facet;
import org.apache.isis.core.metamodel.facetapi.FacetHolder;
import org.apache.isis.core.metamodel.facetapi.FacetUtil;
@@ -44,35 +41,8 @@ public class MustSatisfySpecificationOnPropertyFacetFactory extends FacetFactory
}
private Facet create(final Method method, final FacetHolder holder) {
- return create(Annotations.getAnnotation(method, MustSatisfy.class), holder);
+ return MustSatisfySpecificationFacetForMustSatisfyAnnotationOnProperty.create(Annotations.getAnnotation(method, MustSatisfy.class), holder);
}
- private Facet create(final MustSatisfy annotation, final FacetHolder holder) {
- if (annotation == null) {
- return null;
- }
- final Class<?>[] values = annotation.value();
- final List<Specification> specifications = new ArrayList<Specification>();
- for (final Class<?> value : values) {
- final Specification specification = newSpecificationElseNull(value);
- if (specification != null) {
- specifications.add(specification);
- }
- }
- return specifications.size() > 0 ? new MustSatisfySpecificationOnPropertyFacet(specifications, holder) : null;
- }
-
- private static Specification newSpecificationElseNull(final Class<?> value) {
- if (!(Specification.class.isAssignableFrom(value))) {
- return null;
- }
- try {
- return (Specification) value.newInstance();
- } catch (final InstantiationException e) {
- return null;
- } catch (final IllegalAccessException e) {
- return null;
- }
- }
}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/validating/regexannot/RegExFacetFacetOnPropertyAnnotationFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/validating/regexannot/RegExFacetFacetOnPropertyAnnotationFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/validating/regexannot/RegExFacetFacetOnPropertyAnnotationFactory.java
index 2a35bb0..41829a9 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/validating/regexannot/RegExFacetFacetOnPropertyAnnotationFactory.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/validating/regexannot/RegExFacetFacetOnPropertyAnnotationFactory.java
@@ -42,32 +42,20 @@ public class RegExFacetFacetOnPropertyAnnotationFactory extends FacetFactoryAbst
return;
}
final RegEx annotation = Annotations.getAnnotation(processMethodContext.getMethod(), RegEx.class);
+ if(annotation == null) {
+ return;
+ }
addRegexFacetAndCorrespondingTitleFacet(processMethodContext.getFacetHolder(), annotation);
}
private void addRegexFacetAndCorrespondingTitleFacet(final FacetHolder holder, final RegEx annotation) {
- final RegExFacet regexFacet = createRegexFacet(annotation, holder);
- if (regexFacet == null) {
- return;
- }
+ final RegExFacet regexFacet = RegExFacetOnPropertyAnnotation.createRegexFacet(annotation, holder);
FacetUtil.addFacet(regexFacet);
final TitleFacet titleFacet = createTitleFacet(regexFacet);
FacetUtil.addFacet(titleFacet);
}
- private RegExFacet createRegexFacet(final RegEx annotation, final FacetHolder holder) {
- if (annotation == null) {
- return null;
- }
-
- final String validationExpression = annotation.validation();
- final boolean caseSensitive = annotation.caseSensitive();
- final String formatExpression = annotation.format();
-
- return new RegExFacetOnPropertyAnnotation(validationExpression, formatExpression, caseSensitive, holder);
- }
-
private TitleFacet createTitleFacet(final RegExFacet regexFacet) {
return new TitleFacetFormattedByRegex(regexFacet);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/validating/regexannot/RegExFacetOnPropertyAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/validating/regexannot/RegExFacetOnPropertyAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/validating/regexannot/RegExFacetOnPropertyAnnotation.java
index 6f7f1b2..22cf504 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/validating/regexannot/RegExFacetOnPropertyAnnotation.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/validating/regexannot/RegExFacetOnPropertyAnnotation.java
@@ -20,15 +20,25 @@
package org.apache.isis.core.metamodel.facets.properties.validating.regexannot;
import java.util.regex.Pattern;
-
+import org.apache.isis.applib.annotation.RegEx;
import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.regex.RegExFacet;
import org.apache.isis.core.metamodel.facets.object.regex.RegExFacetAbstract;
public class RegExFacetOnPropertyAnnotation extends RegExFacetAbstract {
private final Pattern pattern;
- public RegExFacetOnPropertyAnnotation(final String validation, final String format, final boolean caseSensitive, final FacetHolder holder) {
+ static RegExFacet createRegexFacet(final RegEx annotation, final FacetHolder holder) {
+
+ final String validationExpression = annotation.validation();
+ final boolean caseSensitive = annotation.caseSensitive();
+ final String formatExpression = annotation.format();
+
+ return new RegExFacetOnPropertyAnnotation(validationExpression, formatExpression, caseSensitive, holder);
+ }
+
+ private RegExFacetOnPropertyAnnotation(final String validation, final String format, final boolean caseSensitive, final FacetHolder holder) {
super(validation, format, caseSensitive, holder);
pattern = Pattern.compile(validation(), patternFlags());
}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/labelat/LabelAtFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/labelat/LabelAtFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/labelat/LabelAtFacet.java
new file mode 100644
index 0000000..457f71b
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/labelat/LabelAtFacet.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.propparam.labelat;
+
+import org.apache.isis.applib.annotation.LabelPosition;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+
+/**
+ * Corresponds to either {@literal @}{@link org.apache.isis.applib.annotation.PropertyLayout#labelPosition()} (for a property) or
+ *{@literal @}{@link org.apache.isis.applib.annotation.ParameterLayout#labelPosition()} (for an action parameter).
+ */
+public interface LabelAtFacet extends Facet {
+
+ /**
+ * The positioning of a property or action parameter's label.
+ */
+ public LabelPosition label();
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/labelat/LabelAtFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/labelat/LabelAtFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/labelat/LabelAtFacetAbstract.java
new file mode 100644
index 0000000..94b476a
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/labelat/LabelAtFacetAbstract.java
@@ -0,0 +1,50 @@
+/*
+ * 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.propparam.labelat;
+
+import org.apache.isis.applib.annotation.LabelPosition;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.MultipleValueFacetAbstract;
+
+public abstract class LabelAtFacetAbstract extends MultipleValueFacetAbstract implements LabelAtFacet {
+
+ public static Class<? extends Facet> type() {
+ return LabelAtFacet.class;
+ }
+
+ private final LabelPosition value;
+
+ public LabelAtFacetAbstract(final LabelPosition value, final FacetHolder holder) {
+ super(type(), holder);
+ this.value = value;
+ }
+
+ @Override
+ public LabelPosition label() {
+ return value;
+ }
+
+ @Override
+ protected String toStringValues() {
+ return "position=" + value;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/labelat/LabelAtFacetInferredFromMultiLineFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/labelat/LabelAtFacetInferredFromMultiLineFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/labelat/LabelAtFacetInferredFromMultiLineFacet.java
new file mode 100644
index 0000000..227990e
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/labelat/LabelAtFacetInferredFromMultiLineFacet.java
@@ -0,0 +1,38 @@
+/*
+ * 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.propparam.labelat;
+
+import org.apache.isis.applib.annotation.LabelPosition;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+
+/**
+ * If multi-line then position the label at the top.
+ *
+ * <p>
+ * This can still be overridden using the {@link org.apache.isis.applib.annotation.PropertyLayout} annotation / layout.json.
+ * </p>
+ */
+public class LabelAtFacetInferredFromMultiLineFacet extends LabelAtFacetAbstract {
+
+ public LabelAtFacetInferredFromMultiLineFacet(final FacetHolder holder) {
+ super(LabelPosition.TOP, holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/layout/LabelAtFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/layout/LabelAtFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/layout/LabelAtFacet.java
deleted file mode 100644
index 8c5452c..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/layout/LabelAtFacet.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.propparam.layout;
-
-import org.apache.isis.applib.annotation.LabelPosition;
-import org.apache.isis.core.metamodel.facetapi.Facet;
-
-/**
- * Corresponds to either {@literal @}{@link org.apache.isis.applib.annotation.PropertyLayout#labelPosition()} (for a property) or
- *{@literal @}{@link org.apache.isis.applib.annotation.ParameterLayout#labelPosition()} (for an action parameter).
- */
-public interface LabelAtFacet extends Facet {
-
- /**
- * The positioning of a property or action parameter's label.
- */
- public LabelPosition label();
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/layout/LabelAtFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/layout/LabelAtFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/layout/LabelAtFacetAbstract.java
deleted file mode 100644
index 2e3d2e6..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/layout/LabelAtFacetAbstract.java
+++ /dev/null
@@ -1,50 +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.propparam.layout;
-
-import org.apache.isis.applib.annotation.LabelPosition;
-import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.MultipleValueFacetAbstract;
-
-public abstract class LabelAtFacetAbstract extends MultipleValueFacetAbstract implements LabelAtFacet {
-
- public static Class<? extends Facet> type() {
- return LabelAtFacet.class;
- }
-
- private final LabelPosition value;
-
- public LabelAtFacetAbstract(final LabelPosition value, final FacetHolder holder) {
- super(type(), holder);
- this.value = value;
- }
-
- @Override
- public LabelPosition label() {
- return value;
- }
-
- @Override
- protected String toStringValues() {
- return "position=" + value;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/layout/LabelAtFacetInferredFromMultiLineFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/layout/LabelAtFacetInferredFromMultiLineFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/layout/LabelAtFacetInferredFromMultiLineFacet.java
deleted file mode 100644
index 5fb3049..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/layout/LabelAtFacetInferredFromMultiLineFacet.java
+++ /dev/null
@@ -1,38 +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.propparam.layout;
-
-import org.apache.isis.applib.annotation.LabelPosition;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-
-/**
- * If multi-line then position the label at the top.
- *
- * <p>
- * This can still be overridden using the {@link org.apache.isis.applib.annotation.PropertyLayout} annotation / layout.json.
- * </p>
- */
-public class LabelAtFacetInferredFromMultiLineFacet extends LabelAtFacetAbstract {
-
- public LabelAtFacetInferredFromMultiLineFacet(final FacetHolder holder) {
- super(LabelPosition.TOP, holder);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/mustsatisfyspec/MustSatisfySpecificationFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/mustsatisfyspec/MustSatisfySpecificationFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/mustsatisfyspec/MustSatisfySpecificationFacet.java
new file mode 100644
index 0000000..d03aa27
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/mustsatisfyspec/MustSatisfySpecificationFacet.java
@@ -0,0 +1,27 @@
+/*
+ * 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.propparam.mustsatisfyspec;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.interactions.ValidatingInteractionAdvisor;
+
+public interface MustSatisfySpecificationFacet extends Facet, ValidatingInteractionAdvisor {
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/mustsatisfyspec/MustSatisfySpecificationFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/mustsatisfyspec/MustSatisfySpecificationFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/mustsatisfyspec/MustSatisfySpecificationFacetAbstract.java
new file mode 100644
index 0000000..6db0d96
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/mustsatisfyspec/MustSatisfySpecificationFacetAbstract.java
@@ -0,0 +1,81 @@
+/*
+ * 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.propparam.mustsatisfyspec;
+
+import java.util.List;
+import org.apache.isis.applib.events.ValidityEvent;
+import org.apache.isis.applib.spec.Specification;
+import org.apache.isis.applib.util.ReasonBuffer;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+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.ProposedHolder;
+import org.apache.isis.core.metamodel.interactions.ValidityContext;
+
+public abstract class MustSatisfySpecificationFacetAbstract extends FacetAbstract implements MustSatisfySpecificationFacet {
+
+ public static Class<? extends Facet> type() {
+ return MustSatisfySpecificationFacet.class;
+ }
+
+ private final List<Specification> specifications;
+
+ public MustSatisfySpecificationFacetAbstract(final List<Specification> specifications, final FacetHolder holder) {
+ super(type(), holder, Derivation.NOT_DERIVED);
+ this.specifications = specifications;
+ }
+
+ @Override
+ public String invalidates(final ValidityContext<? extends ValidityEvent> validityContext) {
+ if (!(validityContext instanceof ProposedHolder)) {
+ return null;
+ }
+ final ProposedHolder proposedHolder = (ProposedHolder) validityContext;
+ final ObjectAdapter proposedAdapter = proposedHolder.getProposed();
+ if(proposedAdapter == null) {
+ return null;
+ }
+ final Object proposedObject = proposedAdapter.getObject();
+ final ReasonBuffer buf = new ReasonBuffer();
+ for (final Specification specification : specifications) {
+ buf.append(specification.satisfies(proposedObject));
+ }
+ return buf.getReason();
+ }
+
+ /**
+ * For benefit of subclasses.
+ */
+ protected static Specification newSpecificationElseNull(final Class<?> value) {
+ if (!(Specification.class.isAssignableFrom(value))) {
+ return null;
+ }
+ try {
+ return (Specification) value.newInstance();
+ } catch (final InstantiationException e) {
+ return null;
+ } catch (final IllegalAccessException e) {
+ return null;
+ }
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/objectstore/jdo/metamodel/facets/prop/column/MandatoryFromJdoColumnAnnotationFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/objectstore/jdo/metamodel/facets/prop/column/MandatoryFromJdoColumnAnnotationFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/objectstore/jdo/metamodel/facets/prop/column/MandatoryFromJdoColumnAnnotationFacetFactory.java
index 528fb27..134e2e5 100644
--- a/core/metamodel/src/main/java/org/apache/isis/objectstore/jdo/metamodel/facets/prop/column/MandatoryFromJdoColumnAnnotationFacetFactory.java
+++ b/core/metamodel/src/main/java/org/apache/isis/objectstore/jdo/metamodel/facets/prop/column/MandatoryFromJdoColumnAnnotationFacetFactory.java
@@ -31,6 +31,7 @@ import org.apache.isis.core.metamodel.facets.Annotations;
import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
import org.apache.isis.core.metamodel.facets.FacetedMethod;
import org.apache.isis.core.metamodel.facets.properties.mandatory.annotation.mandatory.MandatoryFacetOnPropertyMandatoryAnnotation;
+import org.apache.isis.core.metamodel.facets.properties.property.MandatoryFacetForPropertyAnnotation;
import org.apache.isis.core.metamodel.facets.propparam.mandatory.MandatoryFacet;
import org.apache.isis.core.metamodel.facets.propparam.mandatory.MandatoryFacetDefault;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
@@ -70,6 +71,11 @@ public class MandatoryFromJdoColumnAnnotationFacetFactory extends FacetFactoryAb
// an explicit @Mandatory annotation cannot be overridden by @Column annotation
return;
}
+ if (existingFacet instanceof MandatoryFacetForPropertyAnnotation.Required) {
+ // do not replace this facet;
+ // an explicit @Property(optional=FALSE) annotation cannot be overridden by @Column annotation
+ return;
+ }
// TODO: this isn't really good enough; in theory there could be other implementations of view model
// rather than just implementing ViewModel. However, we can't do a lookup of the ObjectSpecification for 'cls'
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/progmodels/dflt/ProgrammingModelFacetsJava5.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/progmodels/dflt/ProgrammingModelFacetsJava5.java b/core/metamodel/src/main/java/org/apache/isis/progmodels/dflt/ProgrammingModelFacetsJava5.java
index 09419f2..905a82d 100644
--- a/core/metamodel/src/main/java/org/apache/isis/progmodels/dflt/ProgrammingModelFacetsJava5.java
+++ b/core/metamodel/src/main/java/org/apache/isis/progmodels/dflt/ProgrammingModelFacetsJava5.java
@@ -173,7 +173,7 @@ import org.apache.isis.core.metamodel.facets.properties.defaults.method.Property
import org.apache.isis.core.metamodel.facets.properties.disabled.fromimmutable.DisabledFacetOnPropertyDerivedFromImmutableFactory;
import org.apache.isis.core.metamodel.facets.properties.disabled.inferred.DisabledFacetOnPropertyInferredFactory;
import org.apache.isis.core.metamodel.facets.properties.interaction.PropertyInteractionFacetFactory;
-import org.apache.isis.core.metamodel.facets.properties.layout.PropertyLayoutFactory;
+import org.apache.isis.core.metamodel.facets.properties.propertylayout.PropertyLayoutFactory;
import org.apache.isis.core.metamodel.facets.properties.mandatory.annotation.mandatory.MandatoryFacetOnPropertyMandatoryAnnotationFactory;
import org.apache.isis.core.metamodel.facets.properties.mandatory.annotation.optional.MandatoryFacetOnPropertyInvertedByOptionalAnnotationFactory;
import org.apache.isis.core.metamodel.facets.properties.mandatory.dflt.MandatoryFacetOnProperyDefaultFactory;
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/param/layout/annotation/LabelAtFacetForParameterLayoutAnnotationFactoryTest.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/param/layout/annotation/LabelAtFacetForParameterLayoutAnnotationFactoryTest.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/param/layout/annotation/LabelAtFacetForParameterLayoutAnnotationFactoryTest.java
index 952df60..ae09d4d 100644
--- a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/param/layout/annotation/LabelAtFacetForParameterLayoutAnnotationFactoryTest.java
+++ b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/param/layout/annotation/LabelAtFacetForParameterLayoutAnnotationFactoryTest.java
@@ -27,7 +27,7 @@ import org.apache.isis.core.metamodel.facets.AbstractFacetFactoryTest;
import org.apache.isis.core.metamodel.facets.FacetFactory;
import org.apache.isis.core.metamodel.facets.param.layout.LabelAtFacetForParameterLayoutAnnotation;
import org.apache.isis.core.metamodel.facets.param.layout.ParameterLayoutFactory;
-import org.apache.isis.core.metamodel.facets.propparam.layout.LabelAtFacet;
+import org.apache.isis.core.metamodel.facets.propparam.labelat.LabelAtFacet;
public class LabelAtFacetForParameterLayoutAnnotationFactoryTest extends AbstractFacetFactoryTest {
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/properties/layout/annotation/LabelAtFacetForPropertyLayoutAnnotationFactoryTest.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/properties/layout/annotation/LabelAtFacetForPropertyLayoutAnnotationFactoryTest.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/properties/layout/annotation/LabelAtFacetForPropertyLayoutAnnotationFactoryTest.java
index 58dfa75..9a842db 100644
--- a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/properties/layout/annotation/LabelAtFacetForPropertyLayoutAnnotationFactoryTest.java
+++ b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/properties/layout/annotation/LabelAtFacetForPropertyLayoutAnnotationFactoryTest.java
@@ -25,9 +25,9 @@ import org.apache.isis.applib.annotation.PropertyLayout;
import org.apache.isis.core.metamodel.facetapi.Facet;
import org.apache.isis.core.metamodel.facets.AbstractFacetFactoryTest;
import org.apache.isis.core.metamodel.facets.FacetFactory.ProcessMethodContext;
-import org.apache.isis.core.metamodel.facets.properties.layout.LabelAtFacetForPropertyLayoutAnnotation;
-import org.apache.isis.core.metamodel.facets.properties.layout.PropertyLayoutFactory;
-import org.apache.isis.core.metamodel.facets.propparam.layout.LabelAtFacet;
+import org.apache.isis.core.metamodel.facets.properties.propertylayout.LabelAtFacetForPropertyLayoutAnnotation;
+import org.apache.isis.core.metamodel.facets.properties.propertylayout.PropertyLayoutFactory;
+import org.apache.isis.core.metamodel.facets.propparam.labelat.LabelAtFacet;
public class LabelAtFacetForPropertyLayoutAnnotationFactoryTest extends AbstractFacetFactoryTest {
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/propparam/specification/MustSatisfySpecificationFacetFactoryProcessParameterTest.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/propparam/specification/MustSatisfySpecificationFacetFactoryProcessParameterTest.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/propparam/specification/MustSatisfySpecificationFacetFactoryProcessParameterTest.java
index b18be50..771e9aa 100644
--- a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/propparam/specification/MustSatisfySpecificationFacetFactoryProcessParameterTest.java
+++ b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/propparam/specification/MustSatisfySpecificationFacetFactoryProcessParameterTest.java
@@ -29,7 +29,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.apache.isis.core.metamodel.facets.FacetFactory.ProcessParameterContext;
import org.apache.isis.core.metamodel.facets.FacetedMethodParameter;
-import org.apache.isis.core.metamodel.facets.param.validating.mustsatisfyspec.MustSatisfySpecificationOnParameterFacet;
+import org.apache.isis.core.metamodel.facets.param.validating.mustsatisfyspec.MustSatisfySpecificationFacetForMustSatisfyAnnotationOnParameter;
import org.apache.isis.core.metamodel.facets.param.validating.mustsatisfyspec.MustSatisfySpecificationOnParameterFacetFactory;
import org.apache.isis.core.unittestsupport.jmocking.JavassistImposteriser;
@@ -66,7 +66,7 @@ public class MustSatisfySpecificationFacetFactoryProcessParameterTest {
mockery.checking(new Expectations() {
{
- one(mockFacetedMethodParameter).addFacet(with(anInstanceOf(MustSatisfySpecificationOnParameterFacet.class)));
+ one(mockFacetedMethodParameter).addFacet(with(anInstanceOf(MustSatisfySpecificationFacetForMustSatisfyAnnotationOnParameter.class)));
}
});
facetFactory.processParams(new ProcessParameterContext(changeLastNameMethodWith, 0, mockFacetedMethodParameter));
@@ -78,7 +78,7 @@ public class MustSatisfySpecificationFacetFactoryProcessParameterTest {
mockery.checking(new Expectations() {
{
- never(mockFacetedMethodParameter).addFacet(with(anInstanceOf(MustSatisfySpecificationOnParameterFacet.class)));
+ never(mockFacetedMethodParameter).addFacet(with(anInstanceOf(MustSatisfySpecificationFacetForMustSatisfyAnnotationOnParameter.class)));
}
});
facetFactory.processParams(new ProcessParameterContext(changeLastNameMethodWithout, 0, mockFacetedMethodParameter));
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/propparam/specification/MustSatisfySpecificationFacetFactoryProcessPropertyTest.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/propparam/specification/MustSatisfySpecificationFacetFactoryProcessPropertyTest.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/propparam/specification/MustSatisfySpecificationFacetFactoryProcessPropertyTest.java
index 67f3512..ee15092 100644
--- a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/propparam/specification/MustSatisfySpecificationFacetFactoryProcessPropertyTest.java
+++ b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/propparam/specification/MustSatisfySpecificationFacetFactoryProcessPropertyTest.java
@@ -28,7 +28,7 @@ import org.junit.Test;
import org.apache.isis.core.metamodel.facetapi.MethodRemover;
import org.apache.isis.core.metamodel.facets.FacetFactory.ProcessMethodContext;
import org.apache.isis.core.metamodel.facets.FacetedMethod;
-import org.apache.isis.core.metamodel.facets.properties.validating.mustsatisfyspec.MustSatisfySpecificationOnPropertyFacet;
+import org.apache.isis.core.metamodel.facets.properties.validating.mustsatisfyspec.MustSatisfySpecificationFacetForMustSatisfyAnnotationOnProperty;
import org.apache.isis.core.metamodel.facets.properties.validating.mustsatisfyspec.MustSatisfySpecificationOnPropertyFacetFactory;
import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
@@ -69,7 +69,7 @@ public class MustSatisfySpecificationFacetFactoryProcessPropertyTest {
mockery.checking(new Expectations() {
{
- one(mockFacetHolder).addFacet(with(anInstanceOf(MustSatisfySpecificationOnPropertyFacet.class)));
+ one(mockFacetHolder).addFacet(with(anInstanceOf(MustSatisfySpecificationFacetForMustSatisfyAnnotationOnProperty.class)));
}
});
facetFactory.process(new ProcessMethodContext(domainObjectClassWithAnnotation.getClass(), null, null, firstNameMethodWith, mockMethodRemover, mockFacetHolder));
@@ -81,7 +81,7 @@ public class MustSatisfySpecificationFacetFactoryProcessPropertyTest {
mockery.checking(new Expectations() {
{
- never(mockFacetHolder).addFacet(with(anInstanceOf(MustSatisfySpecificationOnPropertyFacet.class)));
+ never(mockFacetHolder).addFacet(with(anInstanceOf(MustSatisfySpecificationFacetForMustSatisfyAnnotationOnProperty.class)));
}
});
facetFactory.process(new ProcessMethodContext(domainObjectClassWithAnnotation.getClass(), null, null, firstNameMethodWithout, mockMethodRemover, mockFacetHolder));
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusPersistenceMechanismInstaller.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusPersistenceMechanismInstaller.java b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusPersistenceMechanismInstaller.java
index 1b7ca82..e1d711c 100644
--- a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusPersistenceMechanismInstaller.java
+++ b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusPersistenceMechanismInstaller.java
@@ -202,6 +202,8 @@ public class DataNucleusPersistenceMechanismInstaller extends PersistenceMechani
programmingModel.addFactory(BigDecimalDerivedFromJdoColumnAnnotationFacetFactory.class);
programmingModel.addFactory(MaxLengthDerivedFromJdoColumnAnnotationFacetFactory.class);
// must appear after JdoPrimaryKeyAnnotationFacetFactory (above)
+ // and also MandatoryFacetOnPropertyMandatoryAnnotationFactory
+ // and also PropertyAnnotationFactory
programmingModel.addFactory(MandatoryFromJdoColumnAnnotationFacetFactory.class);
programmingModel.addFactory(AuditableAnnotationInJdoApplibFacetFactory.class);
[2/3] isis git commit: ISIS-970: facet factory for @Property
annotation.
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/optional/MandatoryFacetOnPropertyInvertedByOptionalAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/optional/MandatoryFacetOnPropertyInvertedByOptionalAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/optional/MandatoryFacetOnPropertyInvertedByOptionalAnnotation.java
index 083e250..59294e6 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/optional/MandatoryFacetOnPropertyInvertedByOptionalAnnotation.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/optional/MandatoryFacetOnPropertyInvertedByOptionalAnnotation.java
@@ -19,7 +19,10 @@
package org.apache.isis.core.metamodel.facets.properties.mandatory.annotation.optional;
+import java.lang.reflect.Method;
+import org.apache.isis.applib.annotation.Optional;
import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.propparam.mandatory.MandatoryFacet;
import org.apache.isis.core.metamodel.facets.propparam.mandatory.MandatoryFacetAbstract;
/**
@@ -34,4 +37,12 @@ public class MandatoryFacetOnPropertyInvertedByOptionalAnnotation extends Mandat
public MandatoryFacetOnPropertyInvertedByOptionalAnnotation(final FacetHolder holder) {
super(holder, Semantics.OPTIONAL);
}
+
+ static MandatoryFacet create(final Optional annotation, Method method, final FacetHolder holder) {
+ final Class<?> returnType = method.getReturnType();
+ if (returnType.isPrimitive()) {
+ return null;
+ }
+ return new MandatoryFacetOnPropertyInvertedByOptionalAnnotation(holder);
+ }
}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/optional/MandatoryFacetOnPropertyInvertedByOptionalAnnotationFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/optional/MandatoryFacetOnPropertyInvertedByOptionalAnnotationFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/optional/MandatoryFacetOnPropertyInvertedByOptionalAnnotationFactory.java
index aef6b79..e2f6149 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/optional/MandatoryFacetOnPropertyInvertedByOptionalAnnotationFactory.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/optional/MandatoryFacetOnPropertyInvertedByOptionalAnnotationFactory.java
@@ -19,13 +19,13 @@
package org.apache.isis.core.metamodel.facets.properties.mandatory.annotation.optional;
+import java.lang.reflect.Method;
import org.apache.isis.applib.annotation.Optional;
-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.FacetFactoryAbstract;
-import org.apache.isis.core.metamodel.facets.propparam.mandatory.MandatoryFacet;
+import org.apache.isis.core.metamodel.facets.FacetedMethod;
public class MandatoryFacetOnPropertyInvertedByOptionalAnnotationFactory extends FacetFactoryAbstract {
@@ -35,19 +35,15 @@ public class MandatoryFacetOnPropertyInvertedByOptionalAnnotationFactory extends
@Override
public void process(final ProcessMethodContext processMethodContext) {
- final Class<?> returnType = processMethodContext.getMethod().getReturnType();
- if (returnType.isPrimitive()) {
+ final Method method = processMethodContext.getMethod();
+ final Optional annotation = Annotations.getAnnotation(method, Optional.class);
+ if(annotation == null) {
return;
}
- if (!Annotations.isAnnotationPresent(processMethodContext.getMethod(), Optional.class)) {
- return;
- }
- final Optional annotation = Annotations.getAnnotation(processMethodContext.getMethod(), Optional.class);
- FacetUtil.addFacet(create(annotation, processMethodContext.getFacetHolder()));
- }
+ final FacetedMethod facetHolder = processMethodContext.getFacetHolder();
- private MandatoryFacet create(final Optional annotation, final FacetHolder holder) {
- return annotation != null ? new MandatoryFacetOnPropertyInvertedByOptionalAnnotation(holder) : null;
+ FacetUtil.addFacet(
+ MandatoryFacetOnPropertyInvertedByOptionalAnnotation.create(annotation, method, facetHolder));
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/multiline/annotation/MultiLineFacetOnPropertyFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/multiline/annotation/MultiLineFacetOnPropertyFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/multiline/annotation/MultiLineFacetOnPropertyFactory.java
index 27469ff..84ef727 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/multiline/annotation/MultiLineFacetOnPropertyFactory.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/multiline/annotation/MultiLineFacetOnPropertyFactory.java
@@ -27,7 +27,7 @@ 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.propparam.layout.LabelAtFacetInferredFromMultiLineFacet;
+import org.apache.isis.core.metamodel.facets.propparam.labelat.LabelAtFacetInferredFromMultiLineFacet;
import org.apache.isis.core.metamodel.facets.propparam.multiline.MultiLineFacet;
public class MultiLineFacetOnPropertyFactory extends FacetFactoryAbstract implements ContributeeMemberFacetFactory {
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/notpersisted/annotation/NotPersistedFacetOnPropertyAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/notpersisted/annotation/NotPersistedFacetOnPropertyAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/notpersisted/annotation/NotPersistedFacetOnPropertyAnnotation.java
index e15e8a6..65085fd 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/notpersisted/annotation/NotPersistedFacetOnPropertyAnnotation.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/notpersisted/annotation/NotPersistedFacetOnPropertyAnnotation.java
@@ -19,7 +19,9 @@
package org.apache.isis.core.metamodel.facets.properties.notpersisted.annotation;
+import org.apache.isis.applib.annotation.NotPersisted;
import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.propcoll.notpersisted.NotPersistedFacet;
import org.apache.isis.core.metamodel.facets.propcoll.notpersisted.NotPersistedFacetAbstract;
public class NotPersistedFacetOnPropertyAnnotation extends NotPersistedFacetAbstract {
@@ -28,4 +30,7 @@ public class NotPersistedFacetOnPropertyAnnotation extends NotPersistedFacetAbst
super(holder);
}
+ static NotPersistedFacet create(final NotPersisted annotation, final FacetHolder holder) {
+ return annotation == null ? null : new NotPersistedFacetOnPropertyAnnotation(holder);
+ }
}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/notpersisted/annotation/NotPersistedFacetOnPropertyAnnotationFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/notpersisted/annotation/NotPersistedFacetOnPropertyAnnotationFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/notpersisted/annotation/NotPersistedFacetOnPropertyAnnotationFactory.java
index a4f2ff0..23fdad8 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/notpersisted/annotation/NotPersistedFacetOnPropertyAnnotationFactory.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/notpersisted/annotation/NotPersistedFacetOnPropertyAnnotationFactory.java
@@ -20,7 +20,6 @@
package org.apache.isis.core.metamodel.facets.properties.notpersisted.annotation;
import org.apache.isis.applib.annotation.NotPersisted;
-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;
@@ -36,11 +35,8 @@ public class NotPersistedFacetOnPropertyAnnotationFactory extends FacetFactoryAb
@Override
public void process(final ProcessMethodContext processMethodContext) {
final NotPersisted annotation = Annotations.getAnnotation(processMethodContext.getMethod(), NotPersisted.class);
- FacetUtil.addFacet(create(annotation, processMethodContext.getFacetHolder()));
- }
-
- private NotPersistedFacet create(final NotPersisted annotation, final FacetHolder holder) {
- return annotation == null ? null : new NotPersistedFacetOnPropertyAnnotation(holder);
+ final NotPersistedFacet notPersistedFacet = NotPersistedFacetOnPropertyAnnotation.create(annotation, processMethodContext.getFacetHolder());
+ FacetUtil.addFacet(notPersistedFacet);
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/DisabledFacetForPropertyAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/DisabledFacetForPropertyAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/DisabledFacetForPropertyAnnotation.java
new file mode 100644
index 0000000..dbeeb80
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/DisabledFacetForPropertyAnnotation.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.properties.property;
+
+import org.apache.isis.applib.annotation.EditPolicy;
+import org.apache.isis.applib.annotation.Property;
+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.DisabledFacet;
+import org.apache.isis.core.metamodel.facets.members.disabled.DisabledFacetImpl;
+
+public class DisabledFacetForPropertyAnnotation extends DisabledFacetImpl {
+
+ public static DisabledFacet create(Property property, FacetHolder holder) {
+ final EditPolicy editPolicy = property.editing();
+ final String disabledReason = property.editingDisabledReason();
+
+ switch (editPolicy) {
+ case AS_CONFIGURED:
+
+ // nothing needs to be done here; the DomainObjectFactory (processing @DomainObject annotation)
+ // will install an ImmutableFacetForDomainObjectAnnotation on the domain object and then a
+ // DisabledFacetOnPropertyInferredFromImmutable facet will be installed.
+
+ return null;
+
+ case DISABLED:
+ return new DisabledFacetForPropertyAnnotation(disabledReason, holder);
+ case ENABLED:
+ return null;
+ }
+ return null;
+ }
+
+ private DisabledFacetForPropertyAnnotation(String reason, final FacetHolder holder) {
+ super(When.ALWAYS, Where.EVERYWHERE, reason, holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/MandatoryFacetForPropertyAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/MandatoryFacetForPropertyAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/MandatoryFacetForPropertyAnnotation.java
new file mode 100644
index 0000000..5e22fb2
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/MandatoryFacetForPropertyAnnotation.java
@@ -0,0 +1,72 @@
+/*
+ * 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.properties.property;
+
+import java.lang.reflect.Method;
+import org.apache.isis.applib.annotation.Optionality;
+import org.apache.isis.applib.annotation.Property;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.propparam.mandatory.MandatoryFacet;
+import org.apache.isis.core.metamodel.facets.propparam.mandatory.MandatoryFacetAbstract;
+
+public abstract class MandatoryFacetForPropertyAnnotation extends MandatoryFacetAbstract {
+
+ public MandatoryFacetForPropertyAnnotation(final FacetHolder holder, final Semantics semantics) {
+ super(holder, semantics);
+ }
+
+ static MandatoryFacet create(final Property property, Method method, final FacetHolder holder) {
+ final Class<?> returnType = method.getReturnType();
+ if (returnType.isPrimitive()) {
+ return new MandatoryFacetForPropertyAnnotation.Primitive(holder);
+ }
+ final Optionality optionality = property.optional();
+ switch (optionality) {
+ case DEFAULT:
+ // do nothing here; instead will rely on MandatoryFromJdoColumnAnnotationFacetFactory to perform
+ // the remaining processing
+ return null;
+ case FALSE:
+ return new MandatoryFacetForPropertyAnnotation.Required(holder);
+ case TRUE:
+ return new MandatoryFacetForPropertyAnnotation.Optional(holder);
+ }
+ return null;
+ }
+
+ public static class Primitive extends MandatoryFacetForPropertyAnnotation {
+ public Primitive(final FacetHolder holder) {
+ super(holder, Semantics.REQUIRED);
+ }
+ }
+
+ public static class Required extends MandatoryFacetForPropertyAnnotation {
+ public Required(final FacetHolder holder) {
+ super(holder, Semantics.REQUIRED);
+ }
+ }
+
+ public static class Optional extends MandatoryFacetForPropertyAnnotation {
+ public Optional(final FacetHolder holder) {
+ super(holder, Semantics.OPTIONAL);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/MaxLengthFacetForPropertyAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/MaxLengthFacetForPropertyAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/MaxLengthFacetForPropertyAnnotation.java
new file mode 100644
index 0000000..677eb2a
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/MaxLengthFacetForPropertyAnnotation.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.properties.property;
+
+import org.apache.isis.applib.annotation.Property;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.propparam.maxlen.MaxLengthFacet;
+import org.apache.isis.core.metamodel.facets.propparam.maxlen.MaxLengthFacetAbstract;
+
+public class MaxLengthFacetForPropertyAnnotation extends MaxLengthFacetAbstract {
+
+ public static MaxLengthFacet create(Property property, FacetHolder holder) {
+ final int maxLength = property.maxLength();
+ return maxLength != -1
+ ? new MaxLengthFacetForPropertyAnnotation(maxLength, holder)
+ : null;
+ }
+
+ private MaxLengthFacetForPropertyAnnotation(final int value, final FacetHolder holder) {
+ super(value, holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/MustSatisfySpecificationFacetForPropertyAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/MustSatisfySpecificationFacetForPropertyAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/MustSatisfySpecificationFacetForPropertyAnnotation.java
new file mode 100644
index 0000000..d2859b5
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/MustSatisfySpecificationFacetForPropertyAnnotation.java
@@ -0,0 +1,49 @@
+/*
+ * 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.properties.property;
+
+import java.util.List;
+import com.google.common.collect.Lists;
+import org.apache.isis.applib.annotation.Property;
+import org.apache.isis.applib.spec.Specification;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.propparam.mustsatisfyspec.MustSatisfySpecificationFacetAbstract;
+
+public class MustSatisfySpecificationFacetForPropertyAnnotation extends MustSatisfySpecificationFacetAbstract {
+
+ static Facet create(final Property property, final FacetHolder holder) {
+ final Class<?>[] values = property.mustSatisfy();
+ final List<Specification> specifications = Lists.newArrayList();
+ for (final Class<?> value : values) {
+ final Specification specification = newSpecificationElseNull(value);
+ if (specification != null) {
+ specifications.add(specification);
+ }
+ }
+ return specifications.size() > 0 ? new MustSatisfySpecificationFacetForPropertyAnnotation(specifications, holder) : null;
+ }
+
+
+ private MustSatisfySpecificationFacetForPropertyAnnotation(final List<Specification> specifications, final FacetHolder holder) {
+ super(specifications, holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/NotPersistedFacetForPropertyAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/NotPersistedFacetForPropertyAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/NotPersistedFacetForPropertyAnnotation.java
new file mode 100644
index 0000000..ee16eb6
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/NotPersistedFacetForPropertyAnnotation.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.properties.property;
+
+import org.apache.isis.applib.annotation.Property;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.propcoll.notpersisted.NotPersistedFacet;
+import org.apache.isis.core.metamodel.facets.propcoll.notpersisted.NotPersistedFacetAbstract;
+
+public class NotPersistedFacetForPropertyAnnotation extends NotPersistedFacetAbstract {
+
+ public NotPersistedFacetForPropertyAnnotation(final FacetHolder holder) {
+ super(holder);
+ }
+
+ static NotPersistedFacet create(final Property property, final FacetHolder holder) {
+ final boolean notPersisted = property.notPersisted();
+ final boolean persisted = !notPersisted;
+ if(persisted) {
+ return null;
+ }
+ return new NotPersistedFacetForPropertyAnnotation(holder);
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/PropertyFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/PropertyFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/PropertyFactory.java
new file mode 100644
index 0000000..c6acaa9
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/PropertyFactory.java
@@ -0,0 +1,125 @@
+/*
+ * 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.properties.property;
+
+import java.lang.reflect.Method;
+import org.apache.isis.applib.annotation.Property;
+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.FacetFactoryAbstract;
+import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
+import org.apache.isis.core.metamodel.runtimecontext.ServicesInjectorAware;
+
+public class PropertyFactory extends FacetFactoryAbstract implements ServicesInjectorAware {
+
+ private ServicesInjector servicesInjector;
+
+ public PropertyFactory() {
+ super(FeatureType.PROPERTIES_ONLY);
+ }
+
+ @Override
+ public void process(final ProcessMethodContext processMethodContext) {
+
+ final Method method = processMethodContext.getMethod();
+ final Property property = Annotations.getAnnotation(method, Property.class);
+ if (property == null) {
+ return;
+ }
+
+ processInteraction(processMethodContext);
+ processDisabled(processMethodContext);
+ processMaxLength(processMethodContext);
+ processMustSatisfy(processMethodContext);
+ processNotPersisted(processMethodContext);
+ processOptional(processMethodContext);
+ processRegEx(processMethodContext);
+ }
+
+ private void processInteraction(final ProcessMethodContext processMethodContext) {
+ final Method method = processMethodContext.getMethod();
+ final Property property = Annotations.getAnnotation(method, Property.class);
+ final FacetHolder holder = processMethodContext.getFacetHolder();
+
+ FacetUtil.addFacet(
+ PropertyInteractionFacetForPropertyAnnotation.create(
+ property, servicesInjector, getSpecificationLoader(), holder));
+ }
+
+ private void processDisabled(final ProcessMethodContext processMethodContext) {
+ final Method method = processMethodContext.getMethod();
+ final Property property = Annotations.getAnnotation(method, Property.class);
+ final FacetHolder holder = processMethodContext.getFacetHolder();
+
+ FacetUtil.addFacet(
+ DisabledFacetForPropertyAnnotation.create(property, holder));
+ }
+
+ private void processMaxLength(final ProcessMethodContext processMethodContext) {
+ final Method method = processMethodContext.getMethod();
+ final Property property = Annotations.getAnnotation(method, Property.class);
+ final FacetHolder holder = processMethodContext.getFacetHolder();
+
+ FacetUtil.addFacet(
+ MaxLengthFacetForPropertyAnnotation.create(property, holder));
+ }
+
+ private void processMustSatisfy(final ProcessMethodContext processMethodContext) {
+ final Method method = processMethodContext.getMethod();
+ final Property property = Annotations.getAnnotation(method, Property.class);
+ final FacetHolder holder = processMethodContext.getFacetHolder();
+
+ FacetUtil.addFacet(
+ MustSatisfySpecificationFacetForPropertyAnnotation.create(property, holder));
+ }
+
+ private void processNotPersisted(final ProcessMethodContext processMethodContext) {
+ final Method method = processMethodContext.getMethod();
+ final Property property = Annotations.getAnnotation(method, Property.class);
+ final FacetHolder holder = processMethodContext.getFacetHolder();
+
+ FacetUtil.addFacet(
+ NotPersistedFacetForPropertyAnnotation.create(property, holder));
+ }
+
+ private void processOptional(final ProcessMethodContext processMethodContext) {
+ final Method method = processMethodContext.getMethod();
+ final Property property = Annotations.getAnnotation(method, Property.class);
+ final FacetHolder holder = processMethodContext.getFacetHolder();
+
+ FacetUtil.addFacet(MandatoryFacetForPropertyAnnotation.create(property, method, holder));
+ }
+
+ private void processRegEx(final ProcessMethodContext processMethodContext) {
+ final Method method = processMethodContext.getMethod();
+ final Property property = Annotations.getAnnotation(method, Property.class);
+ final FacetHolder holder = processMethodContext.getFacetHolder();
+
+ FacetUtil.addFacet(RegExFacetForPropertyAnnotation.create(property, holder));
+ }
+
+
+ @Override
+ public void setServicesInjector(final ServicesInjector servicesInjector) {
+ this.servicesInjector = servicesInjector;
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/PropertyInteractionFacetForPropertyAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/PropertyInteractionFacetForPropertyAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/PropertyInteractionFacetForPropertyAnnotation.java
new file mode 100644
index 0000000..a0a66dc
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/PropertyInteractionFacetForPropertyAnnotation.java
@@ -0,0 +1,60 @@
+/*
+ * 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.properties.property;
+
+import org.apache.isis.applib.annotation.Property;
+import org.apache.isis.applib.services.eventbus.PropertyInteractionEvent;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.propcoll.accessor.PropertyOrCollectionAccessorFacet;
+import org.apache.isis.core.metamodel.facets.properties.interaction.PropertyInteractionFacetAbstract;
+import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
+import org.apache.isis.core.metamodel.spec.SpecificationLoader;
+
+public class PropertyInteractionFacetForPropertyAnnotation extends PropertyInteractionFacetAbstract {
+
+ static PropertyInteractionFacetAbstract create(
+ final Property property,
+ final ServicesInjector servicesInjector,
+ final SpecificationLoader specificationLoader,
+ final FacetHolder holder) {
+
+ final PropertyOrCollectionAccessorFacet getterFacet = holder.getFacet(PropertyOrCollectionAccessorFacet.class);
+ if(getterFacet == null) {
+ return null;
+ }
+
+ final Class<? extends PropertyInteractionEvent<?, ?>> interaction = property.interaction();
+ if(interaction == null) {
+ return null;
+ }
+
+ return new PropertyInteractionFacetForPropertyAnnotation(
+ interaction, getterFacet, servicesInjector, specificationLoader, holder);
+ }
+
+ private PropertyInteractionFacetForPropertyAnnotation(
+ final Class<? extends PropertyInteractionEvent<?, ?>> eventType,
+ final PropertyOrCollectionAccessorFacet getterFacet,
+ final ServicesInjector servicesInjector, final SpecificationLoader specificationLoader, final FacetHolder holder) {
+ super(eventType, getterFacet, holder, servicesInjector, specificationLoader);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/RegExFacetForPropertyAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/RegExFacetForPropertyAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/RegExFacetForPropertyAnnotation.java
new file mode 100644
index 0000000..553983a
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/RegExFacetForPropertyAnnotation.java
@@ -0,0 +1,62 @@
+/*
+ * 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.properties.property;
+
+import java.util.regex.Pattern;
+import org.apache.isis.applib.annotation.Property;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.regex.RegExFacet;
+import org.apache.isis.core.metamodel.facets.object.regex.RegExFacetAbstract;
+
+public class RegExFacetForPropertyAnnotation extends RegExFacetAbstract {
+
+ private final Pattern pattern;
+
+ static RegExFacet create(final Property property, final FacetHolder holder) {
+
+ final String pattern = property.regexPattern();
+ final int patternFlags = property.regexPatternFlags();
+
+ return new RegExFacetForPropertyAnnotation(pattern, patternFlags, holder);
+ }
+
+ private RegExFacetForPropertyAnnotation(final String pattern, final int patternFlags, final FacetHolder holder) {
+ super(pattern, "", false, holder);
+ this.pattern = Pattern.compile(pattern, patternFlags);
+ }
+
+ /**
+ * Unused
+ */
+ @Override
+ public String format(String text) {
+ return text;
+ }
+
+ @Override
+ public boolean doesNotMatch(final String text) {
+ if (text == null) {
+ return true;
+ }
+ return !pattern.matcher(text).matches();
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/CssClassFacetForPropertyLayoutAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/CssClassFacetForPropertyLayoutAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/CssClassFacetForPropertyLayoutAnnotation.java
new file mode 100644
index 0000000..a4984b6
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/CssClassFacetForPropertyLayoutAnnotation.java
@@ -0,0 +1,42 @@
+/*
+ * 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.properties.propertylayout;
+
+import com.google.common.base.Strings;
+import org.apache.isis.applib.annotation.PropertyLayout;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.members.cssclass.CssClassFacet;
+import org.apache.isis.core.metamodel.facets.members.cssclass.CssClassFacetAbstract;
+
+public class CssClassFacetForPropertyLayoutAnnotation extends CssClassFacetAbstract {
+
+ public static CssClassFacet create(PropertyLayout propertyLayout, FacetHolder holder) {
+ if(propertyLayout == null) {
+ return null;
+ }
+ final String cssClass = Strings.emptyToNull(propertyLayout.cssClass());
+ return cssClass != null ? new CssClassFacetForPropertyLayoutAnnotation(cssClass, holder) : null;
+ }
+
+ private CssClassFacetForPropertyLayoutAnnotation(String value, FacetHolder holder) {
+ super(value, holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/CssClassFacetOnPropertyFromLayoutProperties.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/CssClassFacetOnPropertyFromLayoutProperties.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/CssClassFacetOnPropertyFromLayoutProperties.java
new file mode 100644
index 0000000..21b1a07
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/CssClassFacetOnPropertyFromLayoutProperties.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.properties.propertylayout;
+
+import java.util.Properties;
+import com.google.common.base.Strings;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.members.cssclass.CssClassFacet;
+import org.apache.isis.core.metamodel.facets.members.cssclass.CssClassFacetAbstract;
+
+public class CssClassFacetOnPropertyFromLayoutProperties extends CssClassFacetAbstract {
+
+ public static CssClassFacet create(Properties properties, FacetHolder holder) {
+ final String cssClass = cssClass(properties);
+ return cssClass != null? new CssClassFacetOnPropertyFromLayoutProperties(cssClass, holder): null;
+ }
+
+ private CssClassFacetOnPropertyFromLayoutProperties(String cssClass, FacetHolder holder) {
+ super(cssClass, holder);
+ }
+
+ private static String cssClass(Properties properties) {
+ if(properties == null) {
+ return null;
+ }
+ return Strings.emptyToNull(properties.getProperty("cssClass"));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/DescribedAsFacetForPropertyLayoutAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/DescribedAsFacetForPropertyLayoutAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/DescribedAsFacetForPropertyLayoutAnnotation.java
new file mode 100644
index 0000000..7a2b062
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/DescribedAsFacetForPropertyLayoutAnnotation.java
@@ -0,0 +1,42 @@
+/*
+ * 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.properties.propertylayout;
+
+import com.google.common.base.Strings;
+import org.apache.isis.applib.annotation.PropertyLayout;
+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 DescribedAsFacetForPropertyLayoutAnnotation extends DescribedAsFacetAbstract {
+
+ public static DescribedAsFacet create(PropertyLayout propertyLayout, FacetHolder holder) {
+ if(propertyLayout == null) {
+ return null;
+ }
+ final String describedAs = Strings.emptyToNull(propertyLayout.describedAs());
+ return describedAs != null ? new DescribedAsFacetForPropertyLayoutAnnotation(describedAs, holder) : null;
+ }
+
+ private DescribedAsFacetForPropertyLayoutAnnotation(String value, FacetHolder holder) {
+ super(value, holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/DescribedAsFacetOnPropertyFromLayoutProperties.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/DescribedAsFacetOnPropertyFromLayoutProperties.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/DescribedAsFacetOnPropertyFromLayoutProperties.java
new file mode 100644
index 0000000..0410c49
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/DescribedAsFacetOnPropertyFromLayoutProperties.java
@@ -0,0 +1,51 @@
+/*
+ * 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.properties.propertylayout;
+
+import java.util.Properties;
+import com.google.common.base.Strings;
+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 DescribedAsFacetOnPropertyFromLayoutProperties extends DescribedAsFacetAbstract {
+
+ public static DescribedAsFacet create(Properties properties, FacetHolder holder) {
+ final String describedAs = describedAs(properties);
+ return describedAs != null? new DescribedAsFacetOnPropertyFromLayoutProperties(describedAs, holder): null;
+ }
+
+ private DescribedAsFacetOnPropertyFromLayoutProperties(String describedAs, FacetHolder holder) {
+ super(describedAs, holder);
+ }
+
+ private static String describedAs(Properties properties) {
+ if(properties == null) {
+ return null;
+ }
+ String describedAs = Strings.emptyToNull(properties.getProperty("describedAs"));
+ if(describedAs == null) {
+ // alternate key
+ describedAs = Strings.emptyToNull(properties.getProperty("description"));
+ }
+ return describedAs;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/HiddenFacetForPropertyLayoutAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/HiddenFacetForPropertyLayoutAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/HiddenFacetForPropertyLayoutAnnotation.java
new file mode 100644
index 0000000..0ee0b82
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/HiddenFacetForPropertyLayoutAnnotation.java
@@ -0,0 +1,52 @@
+/*
+ * 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.properties.propertylayout;
+
+import org.apache.isis.applib.annotation.PropertyLayout;
+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;
+import org.apache.isis.core.metamodel.facets.all.hide.HiddenFacet;
+import org.apache.isis.core.metamodel.facets.members.hidden.HiddenFacetAbstract;
+
+public class HiddenFacetForPropertyLayoutAnnotation extends HiddenFacetAbstract {
+
+ public static HiddenFacet create(final PropertyLayout propertyLayout, final FacetHolder holder) {
+ if (propertyLayout == null) {
+ return null;
+ }
+ final Where where = propertyLayout.hidden();
+ return where != null && where != Where.NOT_SPECIFIED ? new HiddenFacetForPropertyLayoutAnnotation(where, holder) : null;
+ }
+
+ private HiddenFacetForPropertyLayoutAnnotation(final Where where, final FacetHolder holder) {
+ super(When.ALWAYS, where, holder);
+ }
+
+ @Override
+ public String hiddenReason(final ObjectAdapter targetAdapter, final Where whereContext) {
+ if(!where().includes(whereContext)) {
+ return null;
+ }
+ return "Hidden on " + where().getFriendlyName();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/HiddenFacetOnPropertyFromLayoutProperties.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/HiddenFacetOnPropertyFromLayoutProperties.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/HiddenFacetOnPropertyFromLayoutProperties.java
new file mode 100644
index 0000000..3fb9354
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/HiddenFacetOnPropertyFromLayoutProperties.java
@@ -0,0 +1,60 @@
+/*
+ * 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.properties.propertylayout;
+
+import java.util.Properties;
+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;
+import org.apache.isis.core.metamodel.facets.all.hide.HiddenFacet;
+import org.apache.isis.core.metamodel.facets.members.hidden.HiddenFacetAbstract;
+
+public class HiddenFacetOnPropertyFromLayoutProperties extends HiddenFacetAbstract {
+
+ public static HiddenFacet create(Properties properties, FacetHolder holder) {
+ final Where where = hidden(properties);
+ return where != null && where != Where.NOT_SPECIFIED ? new HiddenFacetOnPropertyFromLayoutProperties(where, holder): null;
+ }
+
+ private static Where hidden(Properties properties) {
+ if(properties == null) {
+ return null;
+ }
+ String hidden = Strings.emptyToNull(properties.getProperty("hidden"));
+ if(hidden == null) {
+ return null;
+ }
+ return Where.valueOf(hidden);
+ }
+
+ private HiddenFacetOnPropertyFromLayoutProperties(Where where, FacetHolder holder) {
+ super(When.ALWAYS, where, holder);
+ }
+
+ @Override
+ public String hiddenReason(final ObjectAdapter targetAdapter, Where whereContext) {
+ if(!where().includes(whereContext)) {
+ return null;
+ }
+ return "Hidden on " + where().getFriendlyName();
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/LabelAtFacetForPropertyLayoutAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/LabelAtFacetForPropertyLayoutAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/LabelAtFacetForPropertyLayoutAnnotation.java
new file mode 100644
index 0000000..77d7d65
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/LabelAtFacetForPropertyLayoutAnnotation.java
@@ -0,0 +1,42 @@
+/*
+ * 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.properties.propertylayout;
+
+import org.apache.isis.applib.annotation.LabelPosition;
+import org.apache.isis.applib.annotation.PropertyLayout;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.propparam.labelat.LabelAtFacet;
+import org.apache.isis.core.metamodel.facets.propparam.labelat.LabelAtFacetAbstract;
+
+public class LabelAtFacetForPropertyLayoutAnnotation extends LabelAtFacetAbstract {
+
+ public static LabelAtFacet create(final PropertyLayout propertyLayout, FacetHolder holder) {
+ if (propertyLayout == null) {
+ return null;
+ }
+ final LabelPosition labelPosition = propertyLayout.labelPosition();
+ return labelPosition != null ? new LabelAtFacetForPropertyLayoutAnnotation(labelPosition, holder) : null;
+ }
+
+ private LabelAtFacetForPropertyLayoutAnnotation(final LabelPosition value, final FacetHolder holder) {
+ super(value, holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/LabelAtFacetOnPropertyFromLayoutProperties.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/LabelAtFacetOnPropertyFromLayoutProperties.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/LabelAtFacetOnPropertyFromLayoutProperties.java
new file mode 100644
index 0000000..abd1a67
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/LabelAtFacetOnPropertyFromLayoutProperties.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.properties.propertylayout;
+
+import java.util.Properties;
+import com.google.common.base.Strings;
+import org.apache.isis.applib.annotation.LabelPosition;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.propparam.labelat.LabelAtFacet;
+import org.apache.isis.core.metamodel.facets.propparam.labelat.LabelAtFacetAbstract;
+
+public class LabelAtFacetOnPropertyFromLayoutProperties extends LabelAtFacetAbstract {
+
+ public static LabelAtFacet create(Properties properties, FacetHolder holder) {
+ final LabelPosition labelPosition = labelPosition(properties);
+ return labelPosition != null? new LabelAtFacetOnPropertyFromLayoutProperties(labelPosition, holder): null;
+ }
+
+ private LabelAtFacetOnPropertyFromLayoutProperties(LabelPosition labelPosition, FacetHolder holder) {
+ super(labelPosition, holder);
+ }
+
+ private static LabelPosition labelPosition(Properties properties) {
+ if(properties == null) {
+ return null;
+ }
+ String labelPosition = Strings.emptyToNull(properties.getProperty("labelPosition"));
+ if(labelPosition == null) {
+ // alternative key (cos I keep forgetting which to use).
+ labelPosition = Strings.emptyToNull(properties.getProperty("labelAt"));
+ }
+ if(labelPosition == null) {
+ return null;
+ }
+ return LabelPosition.valueOf(labelPosition);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/MultiLineFacetForPropertyLayoutAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/MultiLineFacetForPropertyLayoutAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/MultiLineFacetForPropertyLayoutAnnotation.java
new file mode 100644
index 0000000..3191115
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/MultiLineFacetForPropertyLayoutAnnotation.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.properties.propertylayout;
+
+import org.apache.isis.applib.annotation.PropertyLayout;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.propparam.multiline.MultiLineFacet;
+import org.apache.isis.core.metamodel.facets.propparam.multiline.MultiLineFacetAbstract;
+
+public class MultiLineFacetForPropertyLayoutAnnotation extends MultiLineFacetAbstract {
+
+ public static MultiLineFacet create(PropertyLayout propertyLayout, FacetHolder holder) {
+ if(propertyLayout == null) {
+ return null;
+ }
+ final int multiLine = propertyLayout.multiLine();
+ return multiLine > 1 ? new MultiLineFacetForPropertyLayoutAnnotation(multiLine, false, holder) : null;
+ }
+
+ private MultiLineFacetForPropertyLayoutAnnotation(int numberOfLines, boolean preventWrapping, FacetHolder holder) {
+ super(numberOfLines, preventWrapping, holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/MultiLineFacetOnPropertyFromLayoutProperties.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/MultiLineFacetOnPropertyFromLayoutProperties.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/MultiLineFacetOnPropertyFromLayoutProperties.java
new file mode 100644
index 0000000..d49b092
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/MultiLineFacetOnPropertyFromLayoutProperties.java
@@ -0,0 +1,49 @@
+/*
+ * 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.properties.propertylayout;
+
+import java.util.Properties;
+import com.google.common.base.Strings;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.propparam.multiline.MultiLineFacet;
+import org.apache.isis.core.metamodel.facets.propparam.multiline.MultiLineFacetAbstract;
+
+public class MultiLineFacetOnPropertyFromLayoutProperties extends MultiLineFacetAbstract {
+
+ public static MultiLineFacet create(Properties properties, FacetHolder holder) {
+ final int multiLine = multiLine(properties);
+ return multiLine > 1? new MultiLineFacetOnPropertyFromLayoutProperties(multiLine, holder): null;
+ }
+
+ private MultiLineFacetOnPropertyFromLayoutProperties(int multiLine, FacetHolder holder) {
+ super(multiLine, false, holder);
+ }
+
+ private static int multiLine(Properties properties) {
+ if(properties == null) {
+ return -1;
+ }
+ String multiLine = Strings.emptyToNull(properties.getProperty("multiLine"));
+ if(multiLine == null) {
+ return -1;
+ }
+ return Integer.parseInt(multiLine);
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/NamedFacetForPropertyLayoutAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/NamedFacetForPropertyLayoutAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/NamedFacetForPropertyLayoutAnnotation.java
new file mode 100644
index 0000000..236ad92
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/NamedFacetForPropertyLayoutAnnotation.java
@@ -0,0 +1,42 @@
+/*
+ * 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.properties.propertylayout;
+
+import com.google.common.base.Strings;
+import org.apache.isis.applib.annotation.PropertyLayout;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.all.named.NamedFacet;
+import org.apache.isis.core.metamodel.facets.all.named.NamedFacetAbstract;
+
+public class NamedFacetForPropertyLayoutAnnotation extends NamedFacetAbstract {
+
+ public static NamedFacet create(PropertyLayout propertyLayout, FacetHolder holder) {
+ if(propertyLayout == null) {
+ return null;
+ }
+ final String named = Strings.emptyToNull(propertyLayout.named());
+ return named != null ? new NamedFacetForPropertyLayoutAnnotation(named, holder) : null;
+ }
+
+ private NamedFacetForPropertyLayoutAnnotation(String value, FacetHolder holder) {
+ super(value, holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/NamedFacetOnPropertyFromLayoutProperties.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/NamedFacetOnPropertyFromLayoutProperties.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/NamedFacetOnPropertyFromLayoutProperties.java
new file mode 100644
index 0000000..a6e265b
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/NamedFacetOnPropertyFromLayoutProperties.java
@@ -0,0 +1,51 @@
+/*
+ * 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.properties.propertylayout;
+
+import java.util.Properties;
+import com.google.common.base.Strings;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.all.named.NamedFacet;
+import org.apache.isis.core.metamodel.facets.all.named.NamedFacetAbstract;
+
+public class NamedFacetOnPropertyFromLayoutProperties extends NamedFacetAbstract {
+
+ public static NamedFacet create(Properties properties, FacetHolder holder) {
+ final String named = named(properties);
+ return named != null? new NamedFacetOnPropertyFromLayoutProperties(named, holder): null;
+ }
+
+ private NamedFacetOnPropertyFromLayoutProperties(String named, FacetHolder holder) {
+ super(named, holder);
+ }
+
+ private static String named(Properties properties) {
+ if(properties == null) {
+ return null;
+ }
+ String named = Strings.emptyToNull(properties.getProperty("named"));
+ if(named == null) {
+ // alternate key
+ named = Strings.emptyToNull(properties.getProperty("name"));
+ }
+ return named;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/PropertyLayoutFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/PropertyLayoutFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/PropertyLayoutFactory.java
new file mode 100644
index 0000000..b9075c3
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/PropertyLayoutFactory.java
@@ -0,0 +1,175 @@
+/*
+ * 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.properties.propertylayout;
+
+import java.util.Properties;
+import org.apache.isis.applib.annotation.PropertyLayout;
+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.facets.all.hide.HiddenFacet;
+import org.apache.isis.core.metamodel.facets.all.named.NamedFacet;
+import org.apache.isis.core.metamodel.facets.members.cssclass.CssClassFacet;
+import org.apache.isis.core.metamodel.facets.objpropparam.typicallen.TypicalLengthFacet;
+import org.apache.isis.core.metamodel.facets.propparam.labelat.LabelAtFacet;
+import org.apache.isis.core.metamodel.facets.propparam.multiline.MultiLineFacet;
+import org.apache.isis.core.metamodel.facets.propparam.renderedadjusted.RenderedAdjustedFacet;
+
+public class PropertyLayoutFactory extends FacetFactoryAbstract implements ContributeeMemberFacetFactory {
+
+ public PropertyLayoutFactory() {
+ super(FeatureType.PROPERTIES_ONLY);
+ }
+
+ @Override
+ public void process(final ProcessMethodContext processMethodContext) {
+
+ final FacetHolder holder = processMethodContext.getFacetHolder();
+
+ Properties properties = processMethodContext.metadataProperties("propertyLayout");
+ if(properties == null) {
+ // alternate key
+ properties = processMethodContext.metadataProperties("layout");
+ }
+ final PropertyLayout propertyLayout = Annotations.getAnnotation(processMethodContext.getMethod(), PropertyLayout.class);
+
+
+ // cssClass
+ CssClassFacet cssClassFacet = CssClassFacetOnPropertyFromLayoutProperties.create(properties, holder);
+ if(cssClassFacet == null) {
+ cssClassFacet = CssClassFacetForPropertyLayoutAnnotation.create(propertyLayout, holder);
+ }
+ FacetUtil.addFacet(cssClassFacet);
+
+
+ // describedAs
+ DescribedAsFacet describedAsFacet = DescribedAsFacetOnPropertyFromLayoutProperties.create(properties, holder);
+ if(describedAsFacet == null) {
+ describedAsFacet = DescribedAsFacetForPropertyLayoutAnnotation.create(propertyLayout, holder);
+ }
+ FacetUtil.addFacet(describedAsFacet);
+
+
+ // hidden
+ HiddenFacet hiddenFacet = HiddenFacetOnPropertyFromLayoutProperties.create(properties, holder);
+ if(hiddenFacet == null) {
+ hiddenFacet = HiddenFacetForPropertyLayoutAnnotation.create(propertyLayout, holder);
+ }
+ FacetUtil.addFacet(hiddenFacet);
+
+
+ // labelAt
+ LabelAtFacet labelAtFacet = LabelAtFacetOnPropertyFromLayoutProperties.create(properties, holder);
+ if(labelAtFacet == null) {
+ labelAtFacet = LabelAtFacetForPropertyLayoutAnnotation.create(propertyLayout, holder);
+ }
+ FacetUtil.addFacet(labelAtFacet);
+
+
+ // multiLine
+ MultiLineFacet multiLineFacet = MultiLineFacetOnPropertyFromLayoutProperties.create(properties, holder);
+ if(multiLineFacet == null) {
+ multiLineFacet = MultiLineFacetForPropertyLayoutAnnotation.create(propertyLayout, holder);
+ }
+ FacetUtil.addFacet(multiLineFacet);
+
+
+ // named
+ NamedFacet namedFacet = NamedFacetOnPropertyFromLayoutProperties.create(properties, holder);
+ if(namedFacet == null) {
+ namedFacet = NamedFacetForPropertyLayoutAnnotation.create(propertyLayout, holder);
+ }
+ FacetUtil.addFacet(namedFacet);
+
+
+ // renderedAsDayBefore
+ RenderedAdjustedFacet renderedAdjustedFacet = RenderedAdjustedFacetOnPropertyFromLayoutProperties.create(properties, holder);
+ if(renderedAdjustedFacet == null) {
+ renderedAdjustedFacet = RenderedAdjustedFacetForPropertyLayoutAnnotation.create(propertyLayout, holder);
+ }
+ FacetUtil.addFacet(renderedAdjustedFacet);
+
+
+ // typicalLength
+ TypicalLengthFacet typicalLengthFacet = TypicalLengthFacetOnPropertyFromLayoutProperties.create(properties, holder);
+ if(typicalLengthFacet == null) {
+ typicalLengthFacet = TypicalLengthFacetForPropertyLayoutAnnotation.create(propertyLayout, holder);
+ }
+ FacetUtil.addFacet(typicalLengthFacet);
+
+ }
+
+ @Override
+ public void process(ProcessContributeeMemberContext processMemberContext) {
+ final FacetHolder holder = processMemberContext.getFacetHolder();
+
+ Properties properties = processMemberContext.metadataProperties("propertyLayout");
+ if(properties == null) {
+ // alternate key
+ properties = processMemberContext.metadataProperties("layout");
+ }
+
+
+ // cssClass
+ CssClassFacet cssClassFacet = CssClassFacetOnPropertyFromLayoutProperties.create(properties, holder);
+ FacetUtil.addFacet(cssClassFacet);
+
+
+ // describedAs
+ DescribedAsFacet describedAsFacet = DescribedAsFacetOnPropertyFromLayoutProperties.create(properties, holder);
+ FacetUtil.addFacet(describedAsFacet);
+
+
+ // hidden
+ HiddenFacet hiddenFacet = HiddenFacetOnPropertyFromLayoutProperties.create(properties, holder);
+ FacetUtil.addFacet(hiddenFacet);
+
+
+ // labelAt
+ LabelAtFacet labelAtFacet = LabelAtFacetOnPropertyFromLayoutProperties.create(properties, holder);
+ FacetUtil.addFacet(labelAtFacet);
+
+
+ // multiLine
+ MultiLineFacet multiLineFacet = MultiLineFacetOnPropertyFromLayoutProperties.create(properties, holder);
+ FacetUtil.addFacet(multiLineFacet);
+
+
+ // named
+ NamedFacet namedFacet = NamedFacetOnPropertyFromLayoutProperties.create(properties, holder);
+ FacetUtil.addFacet(namedFacet);
+
+
+ // renderedAsDayBefore
+ RenderedAdjustedFacet renderedAdjustedFacet = RenderedAdjustedFacetOnPropertyFromLayoutProperties.create(properties, holder);
+ FacetUtil.addFacet(renderedAdjustedFacet);
+
+
+ // typicalLength
+ TypicalLengthFacet typicalLengthFacet = TypicalLengthFacetOnPropertyFromLayoutProperties.create(properties, holder);
+ FacetUtil.addFacet(typicalLengthFacet);
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/RenderedAdjustedFacetForPropertyLayoutAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/RenderedAdjustedFacetForPropertyLayoutAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/RenderedAdjustedFacetForPropertyLayoutAnnotation.java
new file mode 100644
index 0000000..d3e2104
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/RenderedAdjustedFacetForPropertyLayoutAnnotation.java
@@ -0,0 +1,43 @@
+/*
+ * 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.properties.propertylayout;
+
+import org.apache.isis.applib.annotation.PropertyLayout;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.propparam.renderedadjusted.RenderedAdjustedFacet;
+import org.apache.isis.core.metamodel.facets.propparam.renderedadjusted.RenderedAdjustedFacetAbstract;
+
+public class RenderedAdjustedFacetForPropertyLayoutAnnotation extends RenderedAdjustedFacetAbstract {
+
+ public static RenderedAdjustedFacet create(PropertyLayout propertyLayout, FacetHolder holder) {
+ if(propertyLayout == null) {
+ return null;
+ }
+ final boolean renderedAsDayBefore = propertyLayout.renderedAsDayBefore();
+ return renderedAsDayBefore ? new RenderedAdjustedFacetForPropertyLayoutAnnotation(holder) : null;
+ }
+
+ public static final int ADJUST_BY = -1;
+
+ private RenderedAdjustedFacetForPropertyLayoutAnnotation(FacetHolder holder) {
+ super(ADJUST_BY, holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/RenderedAdjustedFacetOnPropertyFromLayoutProperties.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/RenderedAdjustedFacetOnPropertyFromLayoutProperties.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/RenderedAdjustedFacetOnPropertyFromLayoutProperties.java
new file mode 100644
index 0000000..e9755c9
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/RenderedAdjustedFacetOnPropertyFromLayoutProperties.java
@@ -0,0 +1,49 @@
+/*
+ * 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.properties.propertylayout;
+
+import java.util.Properties;
+import com.google.common.base.Strings;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.propparam.renderedadjusted.RenderedAdjustedFacet;
+import org.apache.isis.core.metamodel.facets.propparam.renderedadjusted.RenderedAdjustedFacetAbstract;
+
+public class RenderedAdjustedFacetOnPropertyFromLayoutProperties extends RenderedAdjustedFacetAbstract {
+
+ public static final int ADJUST_BY = -1;
+
+ public static RenderedAdjustedFacet create(Properties properties, FacetHolder holder) {
+ final boolean renderedAsDayBefore = renderedAsDayBefore(properties);
+ return renderedAsDayBefore ? new RenderedAdjustedFacetOnPropertyFromLayoutProperties(holder): null;
+ }
+
+ private RenderedAdjustedFacetOnPropertyFromLayoutProperties(FacetHolder holder) {
+ super(ADJUST_BY, holder);
+ }
+
+ private static boolean renderedAsDayBefore(Properties properties) {
+ if(properties == null) {
+ return false;
+ }
+ String renderedAsDayBefore = Strings.emptyToNull(properties.getProperty("renderedAsDayBefore"));
+ return renderedAsDayBefore != null && Boolean.parseBoolean(renderedAsDayBefore);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/TypicalLengthFacetForPropertyLayoutAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/TypicalLengthFacetForPropertyLayoutAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/TypicalLengthFacetForPropertyLayoutAnnotation.java
new file mode 100644
index 0000000..4a109ad
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/propertylayout/TypicalLengthFacetForPropertyLayoutAnnotation.java
@@ -0,0 +1,49 @@
+/*
+ * 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.properties.propertylayout;
+
+import org.apache.isis.applib.annotation.PropertyLayout;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.objpropparam.typicallen.TypicalLengthFacet;
+import org.apache.isis.core.metamodel.facets.objpropparam.typicallen.TypicalLengthFacetAbstract;
+
+public class TypicalLengthFacetForPropertyLayoutAnnotation extends TypicalLengthFacetAbstract {
+
+ public static TypicalLengthFacet create(PropertyLayout propertyLayout, FacetHolder holder) {
+ if(propertyLayout == null) {
+ return null;
+ }
+ final int typicalLength = propertyLayout.typicalLength();
+ return typicalLength != -1 ? new TypicalLengthFacetForPropertyLayoutAnnotation(typicalLength, holder) : null;
+ }
+
+ private final int typicalLength;
+
+ private TypicalLengthFacetForPropertyLayoutAnnotation(int typicalLength, FacetHolder holder) {
+ super(holder, Derivation.NOT_DERIVED);
+ this.typicalLength = typicalLength;
+ }
+
+ @Override
+ public int value() {
+ return typicalLength;
+ }
+
+}
[3/3] isis git commit: ISIS-970: facet factory for @Property
annotation.
Posted by da...@apache.org.
ISIS-970: facet factory for @Property annotation.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/c0da099a
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/c0da099a
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/c0da099a
Branch: refs/heads/ISIS-970
Commit: c0da099a57601fafe1fde6aa9f1ece3339ce30f3
Parents: 93a81db
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Mon Dec 29 18:01:27 2014 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Mon Dec 29 18:01:27 2014 +0000
----------------------------------------------------------------------
.../components/scalars/ScalarPanelAbstract.java | 4 +-
.../isis/applib/annotation/Cardinality.java | 35 ----
.../isis/applib/annotation/Mandatory.java | 2 +-
.../apache/isis/applib/annotation/Optional.java | 2 +-
.../isis/applib/annotation/Optionality.java | 39 +++++
.../isis/applib/annotation/Parameter.java | 9 +-
.../apache/isis/applib/annotation/Property.java | 14 +-
.../LabelAtFacetFromLayoutConfiguration.java | 2 +-
...abelAtFacetForParameterLayoutAnnotation.java | 4 +-
...tiLineFacetOnParameterAnnotationFactory.java | 2 +-
...acetForMustSatisfyAnnotationOnParameter.java | 52 ++++++
...ustSatisfySpecificationOnParameterFacet.java | 66 -------
...sfySpecificationOnParameterFacetFactory.java | 35 +---
.../PropertyInteractionFacetFactory.java | 1 +
...ssClassFacetForPropertyLayoutAnnotation.java | 42 -----
...lassFacetOnPropertyFromLayoutProperties.java | 46 -----
...ribedAsFacetForPropertyLayoutAnnotation.java | 42 -----
...edAsFacetOnPropertyFromLayoutProperties.java | 51 ------
.../HiddenFacetForPropertyLayoutAnnotation.java | 52 ------
...ddenFacetOnPropertyFromLayoutProperties.java | 60 -------
...LabelAtFacetForPropertyLayoutAnnotation.java | 42 -----
...elAtFacetOnPropertyFromLayoutProperties.java | 55 ------
...ltiLineFacetForPropertyLayoutAnnotation.java | 41 -----
...LineFacetOnPropertyFromLayoutProperties.java | 49 ------
.../NamedFacetForPropertyLayoutAnnotation.java | 42 -----
...amedFacetOnPropertyFromLayoutProperties.java | 51 ------
.../layout/PropertyLayoutFactory.java | 175 -------------------
...djustedFacetForPropertyLayoutAnnotation.java | 43 -----
...stedFacetOnPropertyFromLayoutProperties.java | 49 ------
...lLengthFacetForPropertyLayoutAnnotation.java | 49 ------
...ngthFacetOnPropertyFromLayoutProperties.java | 57 ------
...atoryFacetOnPropertyMandatoryAnnotation.java | 6 +
...cetOnPropertyMandatoryAnnotationFactory.java | 12 +-
...tOnPropertyInvertedByOptionalAnnotation.java | 11 ++
...ertyInvertedByOptionalAnnotationFactory.java | 20 +--
.../MultiLineFacetOnPropertyFactory.java | 2 +-
.../NotPersistedFacetOnPropertyAnnotation.java | 5 +
...rsistedFacetOnPropertyAnnotationFactory.java | 8 +-
.../DisabledFacetForPropertyAnnotation.java | 57 ++++++
.../MandatoryFacetForPropertyAnnotation.java | 72 ++++++++
.../MaxLengthFacetForPropertyAnnotation.java | 40 +++++
...SpecificationFacetForPropertyAnnotation.java | 49 ++++++
.../NotPersistedFacetForPropertyAnnotation.java | 41 +++++
.../properties/property/PropertyFactory.java | 125 +++++++++++++
...tyInteractionFacetForPropertyAnnotation.java | 60 +++++++
.../RegExFacetForPropertyAnnotation.java | 62 +++++++
...ssClassFacetForPropertyLayoutAnnotation.java | 42 +++++
...lassFacetOnPropertyFromLayoutProperties.java | 46 +++++
...ribedAsFacetForPropertyLayoutAnnotation.java | 42 +++++
...edAsFacetOnPropertyFromLayoutProperties.java | 51 ++++++
.../HiddenFacetForPropertyLayoutAnnotation.java | 52 ++++++
...ddenFacetOnPropertyFromLayoutProperties.java | 60 +++++++
...LabelAtFacetForPropertyLayoutAnnotation.java | 42 +++++
...elAtFacetOnPropertyFromLayoutProperties.java | 55 ++++++
...ltiLineFacetForPropertyLayoutAnnotation.java | 41 +++++
...LineFacetOnPropertyFromLayoutProperties.java | 49 ++++++
.../NamedFacetForPropertyLayoutAnnotation.java | 42 +++++
...amedFacetOnPropertyFromLayoutProperties.java | 51 ++++++
.../propertylayout/PropertyLayoutFactory.java | 175 +++++++++++++++++++
...djustedFacetForPropertyLayoutAnnotation.java | 43 +++++
...stedFacetOnPropertyFromLayoutProperties.java | 49 ++++++
...lLengthFacetForPropertyLayoutAnnotation.java | 49 ++++++
...ngthFacetOnPropertyFromLayoutProperties.java | 57 ++++++
...FacetForMustSatisfyAnnotationOnProperty.java | 52 ++++++
...MustSatisfySpecificationOnPropertyFacet.java | 63 -------
...isfySpecificationOnPropertyFacetFactory.java | 32 +---
...ExFacetFacetOnPropertyAnnotationFactory.java | 20 +--
.../RegExFacetOnPropertyAnnotation.java | 14 +-
.../facets/propparam/labelat/LabelAtFacet.java | 36 ++++
.../propparam/labelat/LabelAtFacetAbstract.java | 50 ++++++
.../LabelAtFacetInferredFromMultiLineFacet.java | 38 ++++
.../facets/propparam/layout/LabelAtFacet.java | 36 ----
.../propparam/layout/LabelAtFacetAbstract.java | 50 ------
.../LabelAtFacetInferredFromMultiLineFacet.java | 38 ----
.../MustSatisfySpecificationFacet.java | 27 +++
.../MustSatisfySpecificationFacetAbstract.java | 81 +++++++++
...toryFromJdoColumnAnnotationFacetFactory.java | 6 +
.../dflt/ProgrammingModelFacetsJava5.java | 2 +-
...ForParameterLayoutAnnotationFactoryTest.java | 2 +-
...tForPropertyLayoutAnnotationFactoryTest.java | 6 +-
...icationFacetFactoryProcessParameterTest.java | 6 +-
...ficationFacetFactoryProcessPropertyTest.java | 6 +-
...ataNucleusPersistenceMechanismInstaller.java | 2 +
83 files changed, 1924 insertions(+), 1372 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelAbstract.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelAbstract.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelAbstract.java
index 80793c1..37d9260 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelAbstract.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelAbstract.java
@@ -37,7 +37,7 @@ import org.apache.isis.applib.annotation.ActionLayout;
import org.apache.isis.applib.annotation.Where;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.facets.members.cssclass.CssClassFacet;
-import org.apache.isis.core.metamodel.facets.propparam.layout.LabelAtFacet;
+import org.apache.isis.core.metamodel.facets.propparam.labelat.LabelAtFacet;
import org.apache.isis.core.runtime.system.DeploymentType;
import org.apache.isis.core.runtime.system.context.IsisContext;
import org.apache.isis.viewer.wicket.model.links.LinkAndLabel;
@@ -309,7 +309,7 @@ public abstract class ScalarPanelAbstract extends PanelAbstract<ScalarModel> imp
}
/**
- * Applies the {@literal @}{@link org.apache.isis.core.metamodel.facets.propparam.layout.LabelAtFacet} and also CSS based on
+ * Applies the {@literal @}{@link org.apache.isis.core.metamodel.facets.propparam.labelat.LabelAtFacet} and also CSS based on
* whether any of the associated actions have {@literal @}{@link org.apache.isis.applib.annotation.ActionLayout layout} positioned to
* the {@link org.apache.isis.applib.annotation.ActionLayout.Position#RIGHT right}.
*
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/applib/src/main/java/org/apache/isis/applib/annotation/Cardinality.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/annotation/Cardinality.java b/core/applib/src/main/java/org/apache/isis/applib/annotation/Cardinality.java
deleted file mode 100644
index 005a9ee..0000000
--- a/core/applib/src/main/java/org/apache/isis/applib/annotation/Cardinality.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.apache.isis.applib.annotation;
-
-/**
- * Whether the property or parameter is mandatory or not.
- */
-public enum Cardinality {
- /**
- * Default, usually mandatory (and always so for parameters) unless JDO {@link javax.jdo.annotations.Column}
- * has also specified with {@link javax.jdo.annotations.Column#allowsNull()} set to <code>true</code>.
- */
- DEFAULT,
- /**
- * Indicates that the property or parameter is not mandatory.
- */
- OPTIONAL,
- /**
- * Indicates that the property is mandatory (even if the JDO {@link javax.jdo.annotations.Column} annotation
- * says otherwise).
- *
- * <p>
- * When using the JDO/DataNucleus objectstore, it is sometimes necessary to annotate a property as optional
- * (using {@link javax.jdo.annotations.Column#allowsNull()} set to <code>true</code>), even if the property is
- * logically mandatory. For example, this can occur when the property is in a subtype class that has been
- * "rolled up" to the superclass table using {@link javax.jdo.annotations.Inheritance} with the
- * {@link javax.jdo.annotations.InheritanceStrategy#SUPERCLASS_TABLE superclass}<tt> strategy.
- * </p>
- *
- * <p>
- * This annotation, therefore, is intended to override any objectstore-specific
- * annotation, so that Isis can apply the constraint even though the objectstore
- * is unable to do so.
- * </p>
- */
- MANDATORY
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/applib/src/main/java/org/apache/isis/applib/annotation/Mandatory.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/annotation/Mandatory.java b/core/applib/src/main/java/org/apache/isis/applib/annotation/Mandatory.java
index 0889c8b..72cd08f 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/annotation/Mandatory.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/annotation/Mandatory.java
@@ -46,7 +46,7 @@ import java.lang.annotation.Target;
*
* @see Optional
*
- * @deprecated - use {@link Property#cardinality()} and {@link Parameter#cardinality()} (with {@link org.apache.isis.applib.annotation.Cardinality#MANDATORY}) instead.
+ * @deprecated - use {@link Property#optional()} and {@link Parameter#optional()} (with {@link Optionality#FALSE}) instead.
*/
@Deprecated
@Inherited
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/applib/src/main/java/org/apache/isis/applib/annotation/Optional.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/annotation/Optional.java b/core/applib/src/main/java/org/apache/isis/applib/annotation/Optional.java
index 27c535e..419bd18 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/annotation/Optional.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/annotation/Optional.java
@@ -39,7 +39,7 @@ import java.lang.annotation.Target;
*
* @see Mandatory
*
- * @deprecated - use {@link Property#cardinality()} and {@link Parameter#cardinality()} (with {@link org.apache.isis.applib.annotation.Cardinality#OPTIONAL}) instead.
+ * @deprecated - use {@link Property#optional()} and {@link Parameter#optional()} (with {@link Optionality#TRUE}) instead.
*/
@Deprecated
@Inherited
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/applib/src/main/java/org/apache/isis/applib/annotation/Optionality.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/annotation/Optionality.java b/core/applib/src/main/java/org/apache/isis/applib/annotation/Optionality.java
new file mode 100644
index 0000000..c3a2877
--- /dev/null
+++ b/core/applib/src/main/java/org/apache/isis/applib/annotation/Optionality.java
@@ -0,0 +1,39 @@
+package org.apache.isis.applib.annotation;
+
+/**
+ * Whether the property or parameter is optional or is required (aka mandatory).
+ */
+public enum Optionality {
+ /**
+ * Default, usually false (meaning mandatory) for properties and always false for parameters.
+ *
+ * <p>
+ * For properties, will be false unless JDO {@link javax.jdo.annotations.Column} has also specified with
+ * {@link javax.jdo.annotations.Column#allowsNull()} set to <code>true</code>.
+ * </p>
+ */
+ DEFAULT,
+ /**
+ * Indicates that the property or parameter is not required.
+ */
+ TRUE,
+ /**
+ * Indicates that the property is required (even if the JDO {@link javax.jdo.annotations.Column} annotation
+ * says otherwise).
+ *
+ * <p>
+ * When using the JDO/DataNucleus objectstore, it is sometimes necessary to annotate a property as optional
+ * (using {@link javax.jdo.annotations.Column#allowsNull()} set to <code>true</code>), even if the property is
+ * logically mandatory. For example, this can occur when the property is in a subtype class that has been
+ * "rolled up" to the superclass table using {@link javax.jdo.annotations.Inheritance} with the
+ * {@link javax.jdo.annotations.InheritanceStrategy#SUPERCLASS_TABLE superclass}<tt> strategy.
+ * </p>
+ *
+ * <p>
+ * This annotation, therefore, is intended to override any objectstore-specific
+ * annotation, so that Isis can apply the constraint even though the objectstore
+ * is unable to do so.
+ * </p>
+ */
+ FALSE
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/applib/src/main/java/org/apache/isis/applib/annotation/Parameter.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/annotation/Parameter.java b/core/applib/src/main/java/org/apache/isis/applib/annotation/Parameter.java
index a36f364..b5c31c9 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/annotation/Parameter.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/annotation/Parameter.java
@@ -58,9 +58,14 @@ public @interface Parameter {
// //////////////////////////////////////
/**
- * Whether this parameter is mandatory or optional.
+ * Whether this parameter is optional or is required.
+ *
+ * <p>
+ * For parameters the default value, {@link org.apache.isis.applib.annotation.Optionality#DEFAULT}, is taken
+ * to mean that the parameter is required.
+ * </p>
*/
- Cardinality cardinality() default Cardinality.DEFAULT;
+ Optionality optional() default Optionality.DEFAULT;
// //////////////////////////////////////
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/applib/src/main/java/org/apache/isis/applib/annotation/Property.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/annotation/Property.java b/core/applib/src/main/java/org/apache/isis/applib/annotation/Property.java
index d1f9165..92e82a2 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/annotation/Property.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/annotation/Property.java
@@ -125,9 +125,15 @@ public @interface Property {
// //////////////////////////////////////
/**
- * Whether this property is mandatory or optional.
+ * Whether this property is optional or is required.
+ *
+ * <p>
+ * For properties the default value, {@link org.apache.isis.applib.annotation.Optionality#DEFAULT}, usually
+ * means that the property is required unless it has been overridden by {@link javax.jdo.annotations.Column}
+ * with its {@link javax.jdo.annotations.Column#allowsNull() allowNulls()} attribute set to true.
+ * </p>
*/
- Cardinality cardinality() default Cardinality.DEFAULT;
+ Optionality optional() default Optionality.DEFAULT;
// //////////////////////////////////////
@@ -146,9 +152,5 @@ public @interface Property {
*/
int regexPatternFlags() default 0;
- /**
- * Replacement text for the pattern in generated error message.
- */
- String regexPatternReplacement() default "";
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/fallback/LabelAtFacetFromLayoutConfiguration.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/fallback/LabelAtFacetFromLayoutConfiguration.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/fallback/LabelAtFacetFromLayoutConfiguration.java
index 8c97bbc..997324d 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/fallback/LabelAtFacetFromLayoutConfiguration.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/fallback/LabelAtFacetFromLayoutConfiguration.java
@@ -20,7 +20,7 @@ package org.apache.isis.core.metamodel.facets.fallback;
import org.apache.isis.applib.annotation.LabelPosition;
import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.propparam.layout.LabelAtFacetAbstract;
+import org.apache.isis.core.metamodel.facets.propparam.labelat.LabelAtFacetAbstract;
public class LabelAtFacetFromLayoutConfiguration extends LabelAtFacetAbstract {
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/layout/LabelAtFacetForParameterLayoutAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/layout/LabelAtFacetForParameterLayoutAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/layout/LabelAtFacetForParameterLayoutAnnotation.java
index 41e19bf..7001603 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/layout/LabelAtFacetForParameterLayoutAnnotation.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/layout/LabelAtFacetForParameterLayoutAnnotation.java
@@ -22,8 +22,8 @@ package org.apache.isis.core.metamodel.facets.param.layout;
import org.apache.isis.applib.annotation.LabelPosition;
import org.apache.isis.applib.annotation.ParameterLayout;
import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.propparam.layout.LabelAtFacet;
-import org.apache.isis.core.metamodel.facets.propparam.layout.LabelAtFacetAbstract;
+import org.apache.isis.core.metamodel.facets.propparam.labelat.LabelAtFacet;
+import org.apache.isis.core.metamodel.facets.propparam.labelat.LabelAtFacetAbstract;
public class LabelAtFacetForParameterLayoutAnnotation extends LabelAtFacetAbstract {
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/multiline/annotation/MultiLineFacetOnParameterAnnotationFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/multiline/annotation/MultiLineFacetOnParameterAnnotationFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/multiline/annotation/MultiLineFacetOnParameterAnnotationFactory.java
index 50d2e7a..9976eb1 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/multiline/annotation/MultiLineFacetOnParameterAnnotationFactory.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/multiline/annotation/MultiLineFacetOnParameterAnnotationFactory.java
@@ -26,7 +26,7 @@ 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.FacetFactoryAbstract;
-import org.apache.isis.core.metamodel.facets.propparam.layout.LabelAtFacetInferredFromMultiLineFacet;
+import org.apache.isis.core.metamodel.facets.propparam.labelat.LabelAtFacetInferredFromMultiLineFacet;
import org.apache.isis.core.metamodel.facets.propparam.multiline.MultiLineFacet;
public class MultiLineFacetOnParameterAnnotationFactory extends FacetFactoryAbstract {
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/validating/mustsatisfyspec/MustSatisfySpecificationFacetForMustSatisfyAnnotationOnParameter.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/validating/mustsatisfyspec/MustSatisfySpecificationFacetForMustSatisfyAnnotationOnParameter.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/validating/mustsatisfyspec/MustSatisfySpecificationFacetForMustSatisfyAnnotationOnParameter.java
new file mode 100644
index 0000000..545fb23
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/validating/mustsatisfyspec/MustSatisfySpecificationFacetForMustSatisfyAnnotationOnParameter.java
@@ -0,0 +1,52 @@
+/*
+ * 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.param.validating.mustsatisfyspec;
+
+import java.util.List;
+import com.google.common.collect.Lists;
+import org.apache.isis.applib.annotation.MustSatisfy;
+import org.apache.isis.applib.spec.Specification;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.propparam.mustsatisfyspec.MustSatisfySpecificationFacetAbstract;
+
+public class MustSatisfySpecificationFacetForMustSatisfyAnnotationOnParameter extends MustSatisfySpecificationFacetAbstract {
+
+
+ public static Facet create(final MustSatisfy annotation, final FacetHolder holder) {
+ if (annotation == null) {
+ return null;
+ }
+ final Class<?>[] values = annotation.value();
+ final List<Specification> specifications = Lists.newArrayList();
+ for (final Class<?> value : values) {
+ final Specification specification = newSpecificationElseNull(value);
+ if (specification != null) {
+ specifications.add(specification);
+ }
+ }
+ return specifications.size() > 0 ? new MustSatisfySpecificationFacetForMustSatisfyAnnotationOnParameter(specifications, holder) : null;
+ }
+
+ private MustSatisfySpecificationFacetForMustSatisfyAnnotationOnParameter(final List<Specification> specifications, final FacetHolder holder) {
+ super(specifications, holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/validating/mustsatisfyspec/MustSatisfySpecificationOnParameterFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/validating/mustsatisfyspec/MustSatisfySpecificationOnParameterFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/validating/mustsatisfyspec/MustSatisfySpecificationOnParameterFacet.java
deleted file mode 100644
index b246662..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/validating/mustsatisfyspec/MustSatisfySpecificationOnParameterFacet.java
+++ /dev/null
@@ -1,66 +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.param.validating.mustsatisfyspec;
-
-import java.util.List;
-
-import org.apache.isis.applib.events.ValidityEvent;
-import org.apache.isis.applib.spec.Specification;
-import org.apache.isis.applib.util.ReasonBuffer;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-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.ProposedHolder;
-import org.apache.isis.core.metamodel.interactions.ValidatingInteractionAdvisor;
-import org.apache.isis.core.metamodel.interactions.ValidityContext;
-
-public class MustSatisfySpecificationOnParameterFacet extends FacetAbstract implements ValidatingInteractionAdvisor {
-
- public static Class<? extends Facet> type() {
- return MustSatisfySpecificationOnParameterFacet.class;
- }
-
- private final List<Specification> specifications;
-
- public MustSatisfySpecificationOnParameterFacet(final List<Specification> specifications, final FacetHolder holder) {
- super(type(), holder, Derivation.NOT_DERIVED);
- this.specifications = specifications;
- }
-
- @Override
- public String invalidates(final ValidityContext<? extends ValidityEvent> validityContext) {
- if (!(validityContext instanceof ProposedHolder)) {
- return null;
- }
- final ProposedHolder proposedHolder = (ProposedHolder) validityContext;
- final ObjectAdapter targetNO = proposedHolder.getProposed();
- if(targetNO == null) {
- return null;
- }
- final Object targetObject = targetNO.getObject();
- final ReasonBuffer buf = new ReasonBuffer();
- for (final Specification specification : specifications) {
- buf.append(specification.satisfies(targetObject));
- }
- return buf.getReason();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/validating/mustsatisfyspec/MustSatisfySpecificationOnParameterFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/validating/mustsatisfyspec/MustSatisfySpecificationOnParameterFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/validating/mustsatisfyspec/MustSatisfySpecificationOnParameterFacetFactory.java
index f47194f..0739dbe 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/validating/mustsatisfyspec/MustSatisfySpecificationOnParameterFacetFactory.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/validating/mustsatisfyspec/MustSatisfySpecificationOnParameterFacetFactory.java
@@ -20,13 +20,7 @@
package org.apache.isis.core.metamodel.facets.param.validating.mustsatisfyspec;
import java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.List;
-
import org.apache.isis.applib.annotation.MustSatisfy;
-import org.apache.isis.applib.spec.Specification;
-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.Annotations;
@@ -45,38 +39,11 @@ public class MustSatisfySpecificationOnParameterFacetFactory extends FacetFactor
for (final Annotation parameterAnnotation : parameterAnnotations) {
if (parameterAnnotation instanceof MustSatisfy) {
final MustSatisfy annotation = (MustSatisfy) parameterAnnotation;
- FacetUtil.addFacet(create(annotation, processParameterContext.getFacetHolder()));
+ FacetUtil.addFacet(MustSatisfySpecificationFacetForMustSatisfyAnnotationOnParameter.create(annotation, processParameterContext.getFacetHolder()));
return;
}
}
}
- private Facet create(final MustSatisfy annotation, final FacetHolder holder) {
- if (annotation == null) {
- return null;
- }
- final Class<?>[] values = annotation.value();
- final List<Specification> specifications = new ArrayList<Specification>();
- for (final Class<?> value : values) {
- final Specification specification = newSpecificationElseNull(value);
- if (specification != null) {
- specifications.add(specification);
- }
- }
- return specifications.size() > 0 ? new MustSatisfySpecificationOnParameterFacet(specifications, holder) : null;
- }
-
- private static Specification newSpecificationElseNull(final Class<?> value) {
- if (!(Specification.class.isAssignableFrom(value))) {
- return null;
- }
- try {
- return (Specification) value.newInstance();
- } catch (final InstantiationException e) {
- return null;
- } catch (final IllegalAccessException e) {
- return null;
- }
- }
}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/interaction/PropertyInteractionFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/interaction/PropertyInteractionFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/interaction/PropertyInteractionFacetFactory.java
index 43f8062..c10881d 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/interaction/PropertyInteractionFacetFactory.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/interaction/PropertyInteractionFacetFactory.java
@@ -56,6 +56,7 @@ public class PropertyInteractionFacetFactory extends FacetFactoryAbstract implem
@Override
public void process(final ProcessMethodContext processMethodContext) {
+
final Method method = processMethodContext.getMethod();
FacetedMethod holder = processMethodContext.getFacetHolder();
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/CssClassFacetForPropertyLayoutAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/CssClassFacetForPropertyLayoutAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/CssClassFacetForPropertyLayoutAnnotation.java
deleted file mode 100644
index 8dcdb5a..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/CssClassFacetForPropertyLayoutAnnotation.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.properties.layout;
-
-import com.google.common.base.Strings;
-import org.apache.isis.applib.annotation.PropertyLayout;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.members.cssclass.CssClassFacet;
-import org.apache.isis.core.metamodel.facets.members.cssclass.CssClassFacetAbstract;
-
-public class CssClassFacetForPropertyLayoutAnnotation extends CssClassFacetAbstract {
-
- public static CssClassFacet create(PropertyLayout propertyLayout, FacetHolder holder) {
- if(propertyLayout == null) {
- return null;
- }
- final String cssClass = Strings.emptyToNull(propertyLayout.cssClass());
- return cssClass != null ? new CssClassFacetForPropertyLayoutAnnotation(cssClass, holder) : null;
- }
-
- private CssClassFacetForPropertyLayoutAnnotation(String value, FacetHolder holder) {
- super(value, holder);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/CssClassFacetOnPropertyFromLayoutProperties.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/CssClassFacetOnPropertyFromLayoutProperties.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/CssClassFacetOnPropertyFromLayoutProperties.java
deleted file mode 100644
index bb2ba80..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/CssClassFacetOnPropertyFromLayoutProperties.java
+++ /dev/null
@@ -1,46 +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.properties.layout;
-
-import java.util.Properties;
-import com.google.common.base.Strings;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.members.cssclass.CssClassFacet;
-import org.apache.isis.core.metamodel.facets.members.cssclass.CssClassFacetAbstract;
-
-public class CssClassFacetOnPropertyFromLayoutProperties extends CssClassFacetAbstract {
-
- public static CssClassFacet create(Properties properties, FacetHolder holder) {
- final String cssClass = cssClass(properties);
- return cssClass != null? new CssClassFacetOnPropertyFromLayoutProperties(cssClass, holder): null;
- }
-
- private CssClassFacetOnPropertyFromLayoutProperties(String cssClass, FacetHolder holder) {
- super(cssClass, holder);
- }
-
- private static String cssClass(Properties properties) {
- if(properties == null) {
- return null;
- }
- return Strings.emptyToNull(properties.getProperty("cssClass"));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/DescribedAsFacetForPropertyLayoutAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/DescribedAsFacetForPropertyLayoutAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/DescribedAsFacetForPropertyLayoutAnnotation.java
deleted file mode 100644
index fe370b7..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/DescribedAsFacetForPropertyLayoutAnnotation.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.properties.layout;
-
-import com.google.common.base.Strings;
-import org.apache.isis.applib.annotation.PropertyLayout;
-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 DescribedAsFacetForPropertyLayoutAnnotation extends DescribedAsFacetAbstract {
-
- public static DescribedAsFacet create(PropertyLayout propertyLayout, FacetHolder holder) {
- if(propertyLayout == null) {
- return null;
- }
- final String describedAs = Strings.emptyToNull(propertyLayout.describedAs());
- return describedAs != null ? new DescribedAsFacetForPropertyLayoutAnnotation(describedAs, holder) : null;
- }
-
- private DescribedAsFacetForPropertyLayoutAnnotation(String value, FacetHolder holder) {
- super(value, holder);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/DescribedAsFacetOnPropertyFromLayoutProperties.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/DescribedAsFacetOnPropertyFromLayoutProperties.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/DescribedAsFacetOnPropertyFromLayoutProperties.java
deleted file mode 100644
index c78b7c5..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/DescribedAsFacetOnPropertyFromLayoutProperties.java
+++ /dev/null
@@ -1,51 +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.properties.layout;
-
-import java.util.Properties;
-import com.google.common.base.Strings;
-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 DescribedAsFacetOnPropertyFromLayoutProperties extends DescribedAsFacetAbstract {
-
- public static DescribedAsFacet create(Properties properties, FacetHolder holder) {
- final String describedAs = describedAs(properties);
- return describedAs != null? new DescribedAsFacetOnPropertyFromLayoutProperties(describedAs, holder): null;
- }
-
- private DescribedAsFacetOnPropertyFromLayoutProperties(String describedAs, FacetHolder holder) {
- super(describedAs, holder);
- }
-
- private static String describedAs(Properties properties) {
- if(properties == null) {
- return null;
- }
- String describedAs = Strings.emptyToNull(properties.getProperty("describedAs"));
- if(describedAs == null) {
- // alternate key
- describedAs = Strings.emptyToNull(properties.getProperty("description"));
- }
- return describedAs;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/HiddenFacetForPropertyLayoutAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/HiddenFacetForPropertyLayoutAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/HiddenFacetForPropertyLayoutAnnotation.java
deleted file mode 100644
index 0859060..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/HiddenFacetForPropertyLayoutAnnotation.java
+++ /dev/null
@@ -1,52 +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.properties.layout;
-
-import org.apache.isis.applib.annotation.PropertyLayout;
-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;
-import org.apache.isis.core.metamodel.facets.all.hide.HiddenFacet;
-import org.apache.isis.core.metamodel.facets.members.hidden.HiddenFacetAbstract;
-
-public class HiddenFacetForPropertyLayoutAnnotation extends HiddenFacetAbstract {
-
- public static HiddenFacet create(final PropertyLayout propertyLayout, final FacetHolder holder) {
- if (propertyLayout == null) {
- return null;
- }
- final Where where = propertyLayout.hidden();
- return where != null && where != Where.NOT_SPECIFIED ? new HiddenFacetForPropertyLayoutAnnotation(where, holder) : null;
- }
-
- private HiddenFacetForPropertyLayoutAnnotation(final Where where, final FacetHolder holder) {
- super(When.ALWAYS, where, holder);
- }
-
- @Override
- public String hiddenReason(final ObjectAdapter targetAdapter, final Where whereContext) {
- if(!where().includes(whereContext)) {
- return null;
- }
- return "Hidden on " + where().getFriendlyName();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/HiddenFacetOnPropertyFromLayoutProperties.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/HiddenFacetOnPropertyFromLayoutProperties.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/HiddenFacetOnPropertyFromLayoutProperties.java
deleted file mode 100644
index 4fee80a..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/HiddenFacetOnPropertyFromLayoutProperties.java
+++ /dev/null
@@ -1,60 +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.properties.layout;
-
-import java.util.Properties;
-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;
-import org.apache.isis.core.metamodel.facets.all.hide.HiddenFacet;
-import org.apache.isis.core.metamodel.facets.members.hidden.HiddenFacetAbstract;
-
-public class HiddenFacetOnPropertyFromLayoutProperties extends HiddenFacetAbstract {
-
- public static HiddenFacet create(Properties properties, FacetHolder holder) {
- final Where where = hidden(properties);
- return where != null && where != Where.NOT_SPECIFIED ? new HiddenFacetOnPropertyFromLayoutProperties(where, holder): null;
- }
-
- private static Where hidden(Properties properties) {
- if(properties == null) {
- return null;
- }
- String hidden = Strings.emptyToNull(properties.getProperty("hidden"));
- if(hidden == null) {
- return null;
- }
- return Where.valueOf(hidden);
- }
-
- private HiddenFacetOnPropertyFromLayoutProperties(Where where, FacetHolder holder) {
- super(When.ALWAYS, where, holder);
- }
-
- @Override
- public String hiddenReason(final ObjectAdapter targetAdapter, Where whereContext) {
- if(!where().includes(whereContext)) {
- return null;
- }
- return "Hidden on " + where().getFriendlyName();
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/LabelAtFacetForPropertyLayoutAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/LabelAtFacetForPropertyLayoutAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/LabelAtFacetForPropertyLayoutAnnotation.java
deleted file mode 100644
index aaeba42..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/LabelAtFacetForPropertyLayoutAnnotation.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.properties.layout;
-
-import org.apache.isis.applib.annotation.LabelPosition;
-import org.apache.isis.applib.annotation.PropertyLayout;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.propparam.layout.LabelAtFacet;
-import org.apache.isis.core.metamodel.facets.propparam.layout.LabelAtFacetAbstract;
-
-public class LabelAtFacetForPropertyLayoutAnnotation extends LabelAtFacetAbstract {
-
- public static LabelAtFacet create(final PropertyLayout propertyLayout, FacetHolder holder) {
- if (propertyLayout == null) {
- return null;
- }
- final LabelPosition labelPosition = propertyLayout.labelPosition();
- return labelPosition != null ? new LabelAtFacetForPropertyLayoutAnnotation(labelPosition, holder) : null;
- }
-
- private LabelAtFacetForPropertyLayoutAnnotation(final LabelPosition value, final FacetHolder holder) {
- super(value, holder);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/LabelAtFacetOnPropertyFromLayoutProperties.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/LabelAtFacetOnPropertyFromLayoutProperties.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/LabelAtFacetOnPropertyFromLayoutProperties.java
deleted file mode 100644
index 4981534..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/LabelAtFacetOnPropertyFromLayoutProperties.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.properties.layout;
-
-import java.util.Properties;
-import com.google.common.base.Strings;
-import org.apache.isis.applib.annotation.LabelPosition;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.propparam.layout.LabelAtFacet;
-import org.apache.isis.core.metamodel.facets.propparam.layout.LabelAtFacetAbstract;
-
-public class LabelAtFacetOnPropertyFromLayoutProperties extends LabelAtFacetAbstract {
-
- public static LabelAtFacet create(Properties properties, FacetHolder holder) {
- final LabelPosition labelPosition = labelPosition(properties);
- return labelPosition != null? new LabelAtFacetOnPropertyFromLayoutProperties(labelPosition, holder): null;
- }
-
- private LabelAtFacetOnPropertyFromLayoutProperties(LabelPosition labelPosition, FacetHolder holder) {
- super(labelPosition, holder);
- }
-
- private static LabelPosition labelPosition(Properties properties) {
- if(properties == null) {
- return null;
- }
- String labelPosition = Strings.emptyToNull(properties.getProperty("labelPosition"));
- if(labelPosition == null) {
- // alternative key (cos I keep forgetting which to use).
- labelPosition = Strings.emptyToNull(properties.getProperty("labelAt"));
- }
- if(labelPosition == null) {
- return null;
- }
- return LabelPosition.valueOf(labelPosition);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/MultiLineFacetForPropertyLayoutAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/MultiLineFacetForPropertyLayoutAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/MultiLineFacetForPropertyLayoutAnnotation.java
deleted file mode 100644
index e043092..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/MultiLineFacetForPropertyLayoutAnnotation.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.properties.layout;
-
-import org.apache.isis.applib.annotation.PropertyLayout;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.propparam.multiline.MultiLineFacet;
-import org.apache.isis.core.metamodel.facets.propparam.multiline.MultiLineFacetAbstract;
-
-public class MultiLineFacetForPropertyLayoutAnnotation extends MultiLineFacetAbstract {
-
- public static MultiLineFacet create(PropertyLayout propertyLayout, FacetHolder holder) {
- if(propertyLayout == null) {
- return null;
- }
- final int multiLine = propertyLayout.multiLine();
- return multiLine > 1 ? new MultiLineFacetForPropertyLayoutAnnotation(multiLine, false, holder) : null;
- }
-
- private MultiLineFacetForPropertyLayoutAnnotation(int numberOfLines, boolean preventWrapping, FacetHolder holder) {
- super(numberOfLines, preventWrapping, holder);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/MultiLineFacetOnPropertyFromLayoutProperties.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/MultiLineFacetOnPropertyFromLayoutProperties.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/MultiLineFacetOnPropertyFromLayoutProperties.java
deleted file mode 100644
index 17682f0..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/MultiLineFacetOnPropertyFromLayoutProperties.java
+++ /dev/null
@@ -1,49 +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.properties.layout;
-
-import java.util.Properties;
-import com.google.common.base.Strings;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.propparam.multiline.MultiLineFacet;
-import org.apache.isis.core.metamodel.facets.propparam.multiline.MultiLineFacetAbstract;
-
-public class MultiLineFacetOnPropertyFromLayoutProperties extends MultiLineFacetAbstract {
-
- public static MultiLineFacet create(Properties properties, FacetHolder holder) {
- final int multiLine = multiLine(properties);
- return multiLine > 1? new MultiLineFacetOnPropertyFromLayoutProperties(multiLine, holder): null;
- }
-
- private MultiLineFacetOnPropertyFromLayoutProperties(int multiLine, FacetHolder holder) {
- super(multiLine, false, holder);
- }
-
- private static int multiLine(Properties properties) {
- if(properties == null) {
- return -1;
- }
- String multiLine = Strings.emptyToNull(properties.getProperty("multiLine"));
- if(multiLine == null) {
- return -1;
- }
- return Integer.parseInt(multiLine);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/NamedFacetForPropertyLayoutAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/NamedFacetForPropertyLayoutAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/NamedFacetForPropertyLayoutAnnotation.java
deleted file mode 100644
index ccdfb7e..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/NamedFacetForPropertyLayoutAnnotation.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.properties.layout;
-
-import com.google.common.base.Strings;
-import org.apache.isis.applib.annotation.PropertyLayout;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.all.named.NamedFacet;
-import org.apache.isis.core.metamodel.facets.all.named.NamedFacetAbstract;
-
-public class NamedFacetForPropertyLayoutAnnotation extends NamedFacetAbstract {
-
- public static NamedFacet create(PropertyLayout propertyLayout, FacetHolder holder) {
- if(propertyLayout == null) {
- return null;
- }
- final String named = Strings.emptyToNull(propertyLayout.named());
- return named != null ? new NamedFacetForPropertyLayoutAnnotation(named, holder) : null;
- }
-
- private NamedFacetForPropertyLayoutAnnotation(String value, FacetHolder holder) {
- super(value, holder);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/NamedFacetOnPropertyFromLayoutProperties.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/NamedFacetOnPropertyFromLayoutProperties.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/NamedFacetOnPropertyFromLayoutProperties.java
deleted file mode 100644
index 73513e4..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/NamedFacetOnPropertyFromLayoutProperties.java
+++ /dev/null
@@ -1,51 +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.properties.layout;
-
-import java.util.Properties;
-import com.google.common.base.Strings;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.all.named.NamedFacet;
-import org.apache.isis.core.metamodel.facets.all.named.NamedFacetAbstract;
-
-public class NamedFacetOnPropertyFromLayoutProperties extends NamedFacetAbstract {
-
- public static NamedFacet create(Properties properties, FacetHolder holder) {
- final String named = named(properties);
- return named != null? new NamedFacetOnPropertyFromLayoutProperties(named, holder): null;
- }
-
- private NamedFacetOnPropertyFromLayoutProperties(String named, FacetHolder holder) {
- super(named, holder);
- }
-
- private static String named(Properties properties) {
- if(properties == null) {
- return null;
- }
- String named = Strings.emptyToNull(properties.getProperty("named"));
- if(named == null) {
- // alternate key
- named = Strings.emptyToNull(properties.getProperty("name"));
- }
- return named;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/PropertyLayoutFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/PropertyLayoutFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/PropertyLayoutFactory.java
deleted file mode 100644
index d51458f..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/PropertyLayoutFactory.java
+++ /dev/null
@@ -1,175 +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.properties.layout;
-
-import java.util.Properties;
-import org.apache.isis.applib.annotation.PropertyLayout;
-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.facets.all.hide.HiddenFacet;
-import org.apache.isis.core.metamodel.facets.all.named.NamedFacet;
-import org.apache.isis.core.metamodel.facets.members.cssclass.CssClassFacet;
-import org.apache.isis.core.metamodel.facets.objpropparam.typicallen.TypicalLengthFacet;
-import org.apache.isis.core.metamodel.facets.propparam.layout.LabelAtFacet;
-import org.apache.isis.core.metamodel.facets.propparam.multiline.MultiLineFacet;
-import org.apache.isis.core.metamodel.facets.propparam.renderedadjusted.RenderedAdjustedFacet;
-
-public class PropertyLayoutFactory extends FacetFactoryAbstract implements ContributeeMemberFacetFactory {
-
- public PropertyLayoutFactory() {
- super(FeatureType.PROPERTIES_ONLY);
- }
-
- @Override
- public void process(final ProcessMethodContext processMethodContext) {
-
- final FacetHolder holder = processMethodContext.getFacetHolder();
-
- Properties properties = processMethodContext.metadataProperties("propertyLayout");
- if(properties == null) {
- // alternate key
- properties = processMethodContext.metadataProperties("layout");
- }
- final PropertyLayout propertyLayout = Annotations.getAnnotation(processMethodContext.getMethod(), PropertyLayout.class);
-
-
- // cssClass
- CssClassFacet cssClassFacet = CssClassFacetOnPropertyFromLayoutProperties.create(properties, holder);
- if(cssClassFacet == null) {
- cssClassFacet = CssClassFacetForPropertyLayoutAnnotation.create(propertyLayout, holder);
- }
- FacetUtil.addFacet(cssClassFacet);
-
-
- // describedAs
- DescribedAsFacet describedAsFacet = DescribedAsFacetOnPropertyFromLayoutProperties.create(properties, holder);
- if(describedAsFacet == null) {
- describedAsFacet = DescribedAsFacetForPropertyLayoutAnnotation.create(propertyLayout, holder);
- }
- FacetUtil.addFacet(describedAsFacet);
-
-
- // hidden
- HiddenFacet hiddenFacet = HiddenFacetOnPropertyFromLayoutProperties.create(properties, holder);
- if(hiddenFacet == null) {
- hiddenFacet = HiddenFacetForPropertyLayoutAnnotation.create(propertyLayout, holder);
- }
- FacetUtil.addFacet(hiddenFacet);
-
-
- // labelAt
- LabelAtFacet labelAtFacet = LabelAtFacetOnPropertyFromLayoutProperties.create(properties, holder);
- if(labelAtFacet == null) {
- labelAtFacet = LabelAtFacetForPropertyLayoutAnnotation.create(propertyLayout, holder);
- }
- FacetUtil.addFacet(labelAtFacet);
-
-
- // multiLine
- MultiLineFacet multiLineFacet = MultiLineFacetOnPropertyFromLayoutProperties.create(properties, holder);
- if(multiLineFacet == null) {
- multiLineFacet = MultiLineFacetForPropertyLayoutAnnotation.create(propertyLayout, holder);
- }
- FacetUtil.addFacet(multiLineFacet);
-
-
- // named
- NamedFacet namedFacet = NamedFacetOnPropertyFromLayoutProperties.create(properties, holder);
- if(namedFacet == null) {
- namedFacet = NamedFacetForPropertyLayoutAnnotation.create(propertyLayout, holder);
- }
- FacetUtil.addFacet(namedFacet);
-
-
- // renderedAsDayBefore
- RenderedAdjustedFacet renderedAdjustedFacet = RenderedAdjustedFacetOnPropertyFromLayoutProperties.create(properties, holder);
- if(renderedAdjustedFacet == null) {
- renderedAdjustedFacet = RenderedAdjustedFacetForPropertyLayoutAnnotation.create(propertyLayout, holder);
- }
- FacetUtil.addFacet(renderedAdjustedFacet);
-
-
- // typicalLength
- TypicalLengthFacet typicalLengthFacet = TypicalLengthFacetOnPropertyFromLayoutProperties.create(properties, holder);
- if(typicalLengthFacet == null) {
- typicalLengthFacet = TypicalLengthFacetForPropertyLayoutAnnotation.create(propertyLayout, holder);
- }
- FacetUtil.addFacet(typicalLengthFacet);
-
- }
-
- @Override
- public void process(ProcessContributeeMemberContext processMemberContext) {
- final FacetHolder holder = processMemberContext.getFacetHolder();
-
- Properties properties = processMemberContext.metadataProperties("propertyLayout");
- if(properties == null) {
- // alternate key
- properties = processMemberContext.metadataProperties("layout");
- }
-
-
- // cssClass
- CssClassFacet cssClassFacet = CssClassFacetOnPropertyFromLayoutProperties.create(properties, holder);
- FacetUtil.addFacet(cssClassFacet);
-
-
- // describedAs
- DescribedAsFacet describedAsFacet = DescribedAsFacetOnPropertyFromLayoutProperties.create(properties, holder);
- FacetUtil.addFacet(describedAsFacet);
-
-
- // hidden
- HiddenFacet hiddenFacet = HiddenFacetOnPropertyFromLayoutProperties.create(properties, holder);
- FacetUtil.addFacet(hiddenFacet);
-
-
- // labelAt
- LabelAtFacet labelAtFacet = LabelAtFacetOnPropertyFromLayoutProperties.create(properties, holder);
- FacetUtil.addFacet(labelAtFacet);
-
-
- // multiLine
- MultiLineFacet multiLineFacet = MultiLineFacetOnPropertyFromLayoutProperties.create(properties, holder);
- FacetUtil.addFacet(multiLineFacet);
-
-
- // named
- NamedFacet namedFacet = NamedFacetOnPropertyFromLayoutProperties.create(properties, holder);
- FacetUtil.addFacet(namedFacet);
-
-
- // renderedAsDayBefore
- RenderedAdjustedFacet renderedAdjustedFacet = RenderedAdjustedFacetOnPropertyFromLayoutProperties.create(properties, holder);
- FacetUtil.addFacet(renderedAdjustedFacet);
-
-
- // typicalLength
- TypicalLengthFacet typicalLengthFacet = TypicalLengthFacetOnPropertyFromLayoutProperties.create(properties, holder);
- FacetUtil.addFacet(typicalLengthFacet);
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/RenderedAdjustedFacetForPropertyLayoutAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/RenderedAdjustedFacetForPropertyLayoutAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/RenderedAdjustedFacetForPropertyLayoutAnnotation.java
deleted file mode 100644
index 019d9a2..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/RenderedAdjustedFacetForPropertyLayoutAnnotation.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.properties.layout;
-
-import org.apache.isis.applib.annotation.PropertyLayout;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.propparam.renderedadjusted.RenderedAdjustedFacet;
-import org.apache.isis.core.metamodel.facets.propparam.renderedadjusted.RenderedAdjustedFacetAbstract;
-
-public class RenderedAdjustedFacetForPropertyLayoutAnnotation extends RenderedAdjustedFacetAbstract {
-
- public static RenderedAdjustedFacet create(PropertyLayout propertyLayout, FacetHolder holder) {
- if(propertyLayout == null) {
- return null;
- }
- final boolean renderedAsDayBefore = propertyLayout.renderedAsDayBefore();
- return renderedAsDayBefore ? new RenderedAdjustedFacetForPropertyLayoutAnnotation(holder) : null;
- }
-
- public static final int ADJUST_BY = -1;
-
- private RenderedAdjustedFacetForPropertyLayoutAnnotation(FacetHolder holder) {
- super(ADJUST_BY, holder);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/RenderedAdjustedFacetOnPropertyFromLayoutProperties.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/RenderedAdjustedFacetOnPropertyFromLayoutProperties.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/RenderedAdjustedFacetOnPropertyFromLayoutProperties.java
deleted file mode 100644
index 71d4e4a..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/RenderedAdjustedFacetOnPropertyFromLayoutProperties.java
+++ /dev/null
@@ -1,49 +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.properties.layout;
-
-import java.util.Properties;
-import com.google.common.base.Strings;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.propparam.renderedadjusted.RenderedAdjustedFacet;
-import org.apache.isis.core.metamodel.facets.propparam.renderedadjusted.RenderedAdjustedFacetAbstract;
-
-public class RenderedAdjustedFacetOnPropertyFromLayoutProperties extends RenderedAdjustedFacetAbstract {
-
- public static final int ADJUST_BY = -1;
-
- public static RenderedAdjustedFacet create(Properties properties, FacetHolder holder) {
- final boolean renderedAsDayBefore = renderedAsDayBefore(properties);
- return renderedAsDayBefore ? new RenderedAdjustedFacetOnPropertyFromLayoutProperties(holder): null;
- }
-
- private RenderedAdjustedFacetOnPropertyFromLayoutProperties(FacetHolder holder) {
- super(ADJUST_BY, holder);
- }
-
- private static boolean renderedAsDayBefore(Properties properties) {
- if(properties == null) {
- return false;
- }
- String renderedAsDayBefore = Strings.emptyToNull(properties.getProperty("renderedAsDayBefore"));
- return renderedAsDayBefore != null && Boolean.parseBoolean(renderedAsDayBefore);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/TypicalLengthFacetForPropertyLayoutAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/TypicalLengthFacetForPropertyLayoutAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/TypicalLengthFacetForPropertyLayoutAnnotation.java
deleted file mode 100644
index b90c4c1..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/TypicalLengthFacetForPropertyLayoutAnnotation.java
+++ /dev/null
@@ -1,49 +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.properties.layout;
-
-import org.apache.isis.applib.annotation.PropertyLayout;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.objpropparam.typicallen.TypicalLengthFacet;
-import org.apache.isis.core.metamodel.facets.objpropparam.typicallen.TypicalLengthFacetAbstract;
-
-public class TypicalLengthFacetForPropertyLayoutAnnotation extends TypicalLengthFacetAbstract {
-
- public static TypicalLengthFacet create(PropertyLayout propertyLayout, FacetHolder holder) {
- if(propertyLayout == null) {
- return null;
- }
- final int typicalLength = propertyLayout.typicalLength();
- return typicalLength != -1 ? new TypicalLengthFacetForPropertyLayoutAnnotation(typicalLength, holder) : null;
- }
-
- private final int typicalLength;
-
- private TypicalLengthFacetForPropertyLayoutAnnotation(int typicalLength, FacetHolder holder) {
- super(holder, Derivation.NOT_DERIVED);
- this.typicalLength = typicalLength;
- }
-
- @Override
- public int value() {
- return typicalLength;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/TypicalLengthFacetOnPropertyFromLayoutProperties.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/TypicalLengthFacetOnPropertyFromLayoutProperties.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/TypicalLengthFacetOnPropertyFromLayoutProperties.java
deleted file mode 100644
index a1259c0..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/TypicalLengthFacetOnPropertyFromLayoutProperties.java
+++ /dev/null
@@ -1,57 +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.properties.layout;
-
-import java.util.Properties;
-import com.google.common.base.Strings;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.objpropparam.typicallen.TypicalLengthFacet;
-import org.apache.isis.core.metamodel.facets.objpropparam.typicallen.TypicalLengthFacetAbstract;
-
-public class TypicalLengthFacetOnPropertyFromLayoutProperties extends TypicalLengthFacetAbstract {
-
- private final int typicalLength;
-
- public static TypicalLengthFacet create(Properties properties, FacetHolder holder) {
- final int typicalLength = typicalLength(properties);
- return typicalLength != -1? new TypicalLengthFacetOnPropertyFromLayoutProperties(typicalLength, holder): null;
- }
-
- private TypicalLengthFacetOnPropertyFromLayoutProperties(int typicalLength, FacetHolder holder) {
- super(holder, Derivation.NOT_DERIVED);
- this.typicalLength = typicalLength;
- }
-
- private static int typicalLength(Properties properties) {
- if(properties == null) {
- return -1;
- }
- String typicalLength = Strings.emptyToNull(properties.getProperty("typicalLength"));
- if(typicalLength == null) {
- return -1;
- }
- return Integer.parseInt(typicalLength);
- }
-
- @Override
- public int value() {
- return typicalLength;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/mandatory/MandatoryFacetOnPropertyMandatoryAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/mandatory/MandatoryFacetOnPropertyMandatoryAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/mandatory/MandatoryFacetOnPropertyMandatoryAnnotation.java
index 538dca0..554695d 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/mandatory/MandatoryFacetOnPropertyMandatoryAnnotation.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/mandatory/MandatoryFacetOnPropertyMandatoryAnnotation.java
@@ -19,7 +19,9 @@
package org.apache.isis.core.metamodel.facets.properties.mandatory.annotation.mandatory;
+import org.apache.isis.applib.annotation.Mandatory;
import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.propparam.mandatory.MandatoryFacet;
import org.apache.isis.core.metamodel.facets.propparam.mandatory.MandatoryFacetAbstract;
/**
@@ -34,4 +36,8 @@ public class MandatoryFacetOnPropertyMandatoryAnnotation extends MandatoryFacetA
public MandatoryFacetOnPropertyMandatoryAnnotation(final FacetHolder holder) {
super(holder, Semantics.REQUIRED);
}
+
+ static MandatoryFacet create(final Mandatory annotation, final FacetHolder holder) {
+ return new MandatoryFacetOnPropertyMandatoryAnnotation(holder);
+ }
}
http://git-wip-us.apache.org/repos/asf/isis/blob/c0da099a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/mandatory/MandatoryFacetOnPropertyMandatoryAnnotationFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/mandatory/MandatoryFacetOnPropertyMandatoryAnnotationFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/mandatory/MandatoryFacetOnPropertyMandatoryAnnotationFactory.java
index 1679786..19cbd06 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/mandatory/MandatoryFacetOnPropertyMandatoryAnnotationFactory.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/mandatory/MandatoryFacetOnPropertyMandatoryAnnotationFactory.java
@@ -20,12 +20,10 @@
package org.apache.isis.core.metamodel.facets.properties.mandatory.annotation.mandatory;
import org.apache.isis.applib.annotation.Mandatory;
-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.FacetFactoryAbstract;
-import org.apache.isis.core.metamodel.facets.propparam.mandatory.MandatoryFacet;
public class MandatoryFacetOnPropertyMandatoryAnnotationFactory extends FacetFactoryAbstract {
@@ -35,15 +33,11 @@ public class MandatoryFacetOnPropertyMandatoryAnnotationFactory extends FacetFac
@Override
public void process(final ProcessMethodContext processMethodContext) {
- if (!Annotations.isAnnotationPresent(processMethodContext.getMethod(), Mandatory.class)) {
+ final Mandatory annotation = Annotations.getAnnotation(processMethodContext.getMethod(), Mandatory.class);
+ if(annotation == null) {
return;
}
- final Mandatory annotation = Annotations.getAnnotation(processMethodContext.getMethod(), Mandatory.class);
- FacetUtil.addFacet(create(annotation, processMethodContext.getFacetHolder()));
- }
-
- private MandatoryFacet create(final Mandatory annotation, final FacetHolder holder) {
- return annotation != null ? new MandatoryFacetOnPropertyMandatoryAnnotation(holder) : null;
+ FacetUtil.addFacet(MandatoryFacetOnPropertyMandatoryAnnotation.create(annotation, processMethodContext.getFacetHolder()));
}
}