You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2014/07/11 12:56:19 UTC
[07/61] [partial] ISIS-831: digression: moving progmodel/facets into
metamodel/facets
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/paged/PagedOnParentedCollectionFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/paged/PagedOnParentedCollectionFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/paged/PagedOnParentedCollectionFacetFactory.java
deleted file mode 100644
index 08be26e..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/paged/PagedOnParentedCollectionFacetFactory.java
+++ /dev/null
@@ -1,84 +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.progmodel.facets.paged;
-
-import java.util.Properties;
-
-import org.apache.isis.applib.annotation.Paged;
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.commons.config.IsisConfigurationAware;
-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.object.paged.PagedFacet;
-
-public class PagedOnParentedCollectionFacetFactory extends FacetFactoryAbstract
- implements ContributeeMemberFacetFactory, IsisConfigurationAware {
-
- private IsisConfiguration configuration;
-
- public PagedOnParentedCollectionFacetFactory() {
- super(FeatureType.COLLECTIONS_ONLY);
- }
-
- @Override
- public void process(final ProcessMethodContext processMethodContext) {
-
- PagedFacet pagedFacet = createFromMetadataPropertiesIfPossible(processMethodContext);
- if(pagedFacet == null) {
- pagedFacet = createFromPagedAnnotationIfPossible(processMethodContext);
- }
- // no-op if null
- FacetUtil.addFacet(pagedFacet);
- }
-
- @Override
- public void process(ProcessContributeeMemberContext processMemberContext) {
- final PagedFacet pagedFacet = createFromMetadataPropertiesIfPossible(processMemberContext);
- // no-op if null
- FacetUtil.addFacet(pagedFacet);
- }
-
- private PagedFacet createFromMetadataPropertiesIfPossible(final ProcessContextWithMetadataProperties<?> processMethodContext) {
- final Properties properties = processMethodContext.metadataProperties("paged");
- return properties != null ? new PagedFacetProperties(properties, processMethodContext.getFacetHolder()) : null;
- }
-
- private PagedFacet createFromPagedAnnotationIfPossible(final ProcessMethodContext processMethodContext) {
- final Paged annotation = Annotations.getAnnotation(processMethodContext.getMethod(), Paged.class);
- return annotation != null ? new PagedFacetAnnotation(processMethodContext.getFacetHolder(), annotation.value()) : null;
- }
-
-
- // //////////////////////////////////////
-
- public IsisConfiguration getConfiguration() {
- return configuration;
- }
-
- @Override
- public void setConfiguration(IsisConfiguration configuration) {
- this.configuration = configuration;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/autocomplete/ActionParameterAutoCompleteFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/autocomplete/ActionParameterAutoCompleteFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/autocomplete/ActionParameterAutoCompleteFacetAbstract.java
deleted file mode 100644
index a53cee8..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/autocomplete/ActionParameterAutoCompleteFacetAbstract.java
+++ /dev/null
@@ -1,64 +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.progmodel.facets.param.autocomplete;
-
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
-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.facets.param.autocomplete.ActionParameterAutoCompleteFacet;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.SpecificationLoader;
-
-public abstract class ActionParameterAutoCompleteFacetAbstract extends FacetAbstract implements ActionParameterAutoCompleteFacet {
-
- public static Class<? extends Facet> type() {
- return ActionParameterAutoCompleteFacet.class;
- }
-
- private final SpecificationLoader specificationLookup;
- private final AdapterManager adapterManager;
-
- public ActionParameterAutoCompleteFacetAbstract(final FacetHolder holder, final SpecificationLoader specificationLookup, final AdapterManager adapterManager) {
- super(type(), holder, Derivation.NOT_DERIVED);
- this.specificationLookup = specificationLookup;
- this.adapterManager = adapterManager;
- }
-
- protected ObjectSpecification getSpecification(final Class<?> type) {
- return type != null ? getSpecificationLookup().loadSpecification(type) : null;
- }
-
- @Override
- public abstract int getMinLength();
-
- // /////////////////////////////////////////////////////////
- // Dependencies
- // /////////////////////////////////////////////////////////
-
- protected SpecificationLoader getSpecificationLookup() {
- return specificationLookup;
- }
-
- protected AdapterManager getAdapterManager() {
- return adapterManager;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/autocomplete/ActionParameterAutoCompleteFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/autocomplete/ActionParameterAutoCompleteFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/autocomplete/ActionParameterAutoCompleteFacetFactory.java
deleted file mode 100644
index db9f189..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/autocomplete/ActionParameterAutoCompleteFacetFactory.java
+++ /dev/null
@@ -1,113 +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.progmodel.facets.param.autocomplete;
-
-import java.lang.reflect.Array;
-import java.lang.reflect.Method;
-import java.util.List;
-
-import org.apache.isis.core.commons.lang.StringExtensions;
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManagerAware;
-import org.apache.isis.core.metamodel.facetapi.FacetUtil;
-import org.apache.isis.core.metamodel.facetapi.FeatureType;
-import org.apache.isis.core.metamodel.facets.FacetedMethod;
-import org.apache.isis.core.metamodel.facets.FacetedMethodParameter;
-import org.apache.isis.core.metamodel.methodutils.MethodScope;
-import org.apache.isis.core.progmodel.facets.MethodFinderUtils;
-import org.apache.isis.core.progmodel.facets.MethodPrefixBasedFacetFactoryAbstract;
-import org.apache.isis.core.progmodel.facets.MethodPrefixConstants;
-
-public class ActionParameterAutoCompleteFacetFactory extends MethodPrefixBasedFacetFactoryAbstract implements AdapterManagerAware {
-
- private static final String[] PREFIXES = {"autoComplete"};
-
- private AdapterManager adapterManager;
-
- public ActionParameterAutoCompleteFacetFactory() {
- super(FeatureType.ACTIONS_ONLY, OrphanValidation.VALIDATE, PREFIXES);
- }
-
- // ///////////////////////////////////////////////////////
- // Actions
- // ///////////////////////////////////////////////////////
-
- @Override
- public void process(final ProcessMethodContext processMethodContext) {
-
- final FacetedMethod facetedMethod = processMethodContext.getFacetHolder();
- final List<FacetedMethodParameter> holderList = facetedMethod.getParameters();
-
- attachAutoCompleteFacetForParametersIfAutoCompleteNumMethodIsFound(processMethodContext, holderList);
-
- }
-
- private void attachAutoCompleteFacetForParametersIfAutoCompleteNumMethodIsFound(final ProcessMethodContext processMethodContext, final List<FacetedMethodParameter> parameters) {
-
- if (parameters.isEmpty()) {
- return;
- }
-
- final Method actionMethod = processMethodContext.getMethod();
- final Class<?>[] params = actionMethod.getParameterTypes();
-
- for (int i = 0; i < params.length; i++) {
-
- final Class<?> paramType = params[i];
- final Class<?> arrayOfParamType = (Array.newInstance(paramType, 0)).getClass();
-
- Method autoCompleteMethod = findAutoCompleteNumMethodReturning(processMethodContext, i, arrayOfParamType);
- if (autoCompleteMethod == null) {
- autoCompleteMethod = findAutoCompleteNumMethodReturning(processMethodContext, i, List.class);
- }
- if (autoCompleteMethod == null) {
- continue;
- }
- processMethodContext.removeMethod(autoCompleteMethod);
-
- // add facets directly to parameters, not to actions
- final FacetedMethodParameter paramAsHolder = parameters.get(i);
- FacetUtil.addFacet(new ActionParameterAutoCompleteFacetViaMethod(autoCompleteMethod, paramType, paramAsHolder, getSpecificationLoader(), getAdapterManager()));
- }
- }
-
- private Method findAutoCompleteNumMethodReturning(final ProcessMethodContext processMethodContext, final int i, final Class<?> paramType) {
-
- final Class<?> cls = processMethodContext.getCls();
- final Method actionMethod = processMethodContext.getMethod();
- final String capitalizedName = StringExtensions.asCapitalizedName(actionMethod.getName());
- final String name = MethodPrefixConstants.AUTO_COMPLETE_PREFIX + i + capitalizedName;
- return MethodFinderUtils.findMethod(cls, MethodScope.OBJECT, name, paramType, new Class[]{String.class});
- }
-
- // ///////////////////////////////////////////////////////////////
- // Dependencies
- // ///////////////////////////////////////////////////////////////
-
- @Override
- public void setAdapterManager(final AdapterManager adapterManager) {
- this.adapterManager = adapterManager;
- }
-
- private AdapterManager getAdapterManager() {
- return adapterManager;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/autocomplete/ActionParameterAutoCompleteFacetViaMethod.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/autocomplete/ActionParameterAutoCompleteFacetViaMethod.java b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/autocomplete/ActionParameterAutoCompleteFacetViaMethod.java
deleted file mode 100644
index 34ad250..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/autocomplete/ActionParameterAutoCompleteFacetViaMethod.java
+++ /dev/null
@@ -1,99 +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.progmodel.facets.param.autocomplete;
-
-import java.lang.reflect.Method;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.isis.core.commons.lang.ObjectExtensions;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
-import org.apache.isis.core.metamodel.adapter.util.AdapterInvokeUtils;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.ImperativeFacet;
-import org.apache.isis.core.metamodel.facets.ImperativeFacet.Intent;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.SpecificationLoader;
-import org.apache.isis.core.progmodel.facets.CollectionUtils;
-
-public class ActionParameterAutoCompleteFacetViaMethod extends ActionParameterAutoCompleteFacetAbstract implements ImperativeFacet {
-
- private final Method method;
- private final Class<?> choicesType;
- private final int minLength;
-
- public ActionParameterAutoCompleteFacetViaMethod(final Method method, final Class<?> choicesType, final FacetHolder holder, final SpecificationLoader specificationLookup, final AdapterManager adapterManager) {
- super(holder, specificationLookup, adapterManager);
- this.method = method;
- this.choicesType = choicesType;
- this.minLength = MinLengthUtil.determineMinLength(method);
- }
-
- /**
- * Returns a singleton list of the {@link Method} provided in the
- * constructor.
- */
- @Override
- public List<Method> getMethods() {
- return Collections.singletonList(method);
- }
-
- @Override
- public Intent getIntent(final Method method) {
- return Intent.CHOICES_OR_AUTOCOMPLETE;
- }
-
- @Override
- public int getMinLength() {
- return minLength;
- }
-
- @Override
- public boolean impliesResolve() {
- return true;
- }
-
- @Override
- public boolean impliesObjectChanged() {
- return false;
- }
-
- @Override
- public Object[] autoComplete(ObjectAdapter owningAdapter, String searchArg) {
- final Object options = AdapterInvokeUtils.invoke(method, owningAdapter, searchArg);
- if (options == null) {
- return new Object[0];
- }
- if (options.getClass().isArray()) {
- return ObjectExtensions.asArray(options);
- } else {
- final ObjectSpecification specification = getSpecification(choicesType);
- return CollectionUtils.getCollectionAsObjectArray(options, specification, getAdapterManager());
- }
- }
-
- @Override
- protected String toStringValues() {
- return "method=" + method + ",type=" + choicesType;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/autocomplete/MinLengthUtil.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/autocomplete/MinLengthUtil.java b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/autocomplete/MinLengthUtil.java
deleted file mode 100644
index 9f77c38..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/autocomplete/MinLengthUtil.java
+++ /dev/null
@@ -1,48 +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.progmodel.facets.param.autocomplete;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-
-import org.apache.isis.applib.annotation.MinLength;
-
-public class MinLengthUtil {
-
- /**
- * Finds the value of the {@link MinLength} annotation on the first parameter of the
- * supplied method.
- */
- public static int determineMinLength(final Method method) {
- final Annotation[][] parameterAnnotations = method.getParameterAnnotations();
- if(parameterAnnotations.length == 1) {
- final Annotation[] searchArgAnnotations = parameterAnnotations[0];
- for(Annotation annotation: searchArgAnnotations) {
- if(annotation instanceof MinLength) {
- MinLength minLength = (MinLength) annotation;
- return minLength.value();
- }
- }
- }
- return MinLengthUtil.MIN_LENGTH_DEFAULT;
- }
-
- public static final int MIN_LENGTH_DEFAULT = 1;
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/choices/ActionParameterChoicesFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/choices/ActionParameterChoicesFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/choices/ActionParameterChoicesFacetAbstract.java
deleted file mode 100644
index 2ffc34f..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/choices/ActionParameterChoicesFacetAbstract.java
+++ /dev/null
@@ -1,61 +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.progmodel.facets.param.choices;
-
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
-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.facets.param.choices.ActionParameterChoicesFacet;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.SpecificationLoader;
-
-public abstract class ActionParameterChoicesFacetAbstract extends FacetAbstract implements ActionParameterChoicesFacet {
-
- public static Class<? extends Facet> type() {
- return ActionParameterChoicesFacet.class;
- }
-
- private final SpecificationLoader specificationLookup;
- private final AdapterManager adapterManager;
-
- public ActionParameterChoicesFacetAbstract(final FacetHolder holder, final SpecificationLoader specificationLookup, final AdapterManager adapterManager) {
- super(type(), holder, Derivation.NOT_DERIVED);
- this.specificationLookup = specificationLookup;
- this.adapterManager = adapterManager;
- }
-
- protected ObjectSpecification getSpecification(final Class<?> type) {
- return type != null ? getSpecificationLookup().loadSpecification(type) : null;
- }
-
- // /////////////////////////////////////////////////////////
- // Dependencies
- // /////////////////////////////////////////////////////////
-
- protected SpecificationLoader getSpecificationLookup() {
- return specificationLookup;
- }
-
- protected AdapterManager getAdapterManager() {
- return adapterManager;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/choices/ActionParameterChoicesFacetNone.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/choices/ActionParameterChoicesFacetNone.java b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/choices/ActionParameterChoicesFacetNone.java
deleted file mode 100644
index 4f39e7a..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/choices/ActionParameterChoicesFacetNone.java
+++ /dev/null
@@ -1,45 +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.progmodel.facets.param.choices;
-
-import java.util.List;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.spec.SpecificationLoader;
-
-public class ActionParameterChoicesFacetNone extends ActionParameterChoicesFacetAbstract {
-
- public ActionParameterChoicesFacetNone(final FacetHolder holder, final SpecificationLoader specificationLookup, final AdapterManager adapterManager) {
- super(holder, specificationLookup, adapterManager);
- }
-
- @Override
- public Object[] getChoices(final ObjectAdapter adapter, final List<ObjectAdapter> arguments) {
- return new ObjectAdapter[0];
- }
-
- @Override
- public boolean isNoop() {
- return true;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/choices/enums/ActionParameterChoicesFacetDerivedFromChoicesFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/choices/enums/ActionParameterChoicesFacetDerivedFromChoicesFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/choices/enums/ActionParameterChoicesFacetDerivedFromChoicesFacet.java
deleted file mode 100644
index 7701222..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/choices/enums/ActionParameterChoicesFacetDerivedFromChoicesFacet.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.progmodel.facets.param.choices.enums;
-
-import java.util.List;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.TypedHolder;
-import org.apache.isis.core.metamodel.facets.choices.ChoicesFacet;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.SpecificationLoader;
-import org.apache.isis.core.progmodel.facets.param.choices.ActionParameterChoicesFacetAbstract;
-
-public class ActionParameterChoicesFacetDerivedFromChoicesFacet extends ActionParameterChoicesFacetAbstract {
-
- public ActionParameterChoicesFacetDerivedFromChoicesFacet(final FacetHolder holder, final SpecificationLoader specificationLookup, final AdapterManager adapterManager) {
- super(holder, specificationLookup, adapterManager);
- }
-
- @Override
- public Object[] getChoices(final ObjectAdapter adapter, final List<ObjectAdapter> arguments) {
- final FacetHolder facetHolder = getFacetHolder();
- final TypedHolder paramPeer = (TypedHolder) facetHolder;
- final ObjectSpecification noSpec = getSpecification(paramPeer.getType());
- final ChoicesFacet choicesFacet = noSpec.getFacet(ChoicesFacet.class);
- if (choicesFacet == null) {
- return new Object[0];
- }
- return choicesFacet.getChoices(adapter);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/choices/enums/ParameterChoicesFacetDerivedFromChoicesFacetFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/choices/enums/ParameterChoicesFacetDerivedFromChoicesFacetFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/choices/enums/ParameterChoicesFacetDerivedFromChoicesFacetFacetFactory.java
deleted file mode 100644
index 139a6fb..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/choices/enums/ParameterChoicesFacetDerivedFromChoicesFacetFacetFactory.java
+++ /dev/null
@@ -1,68 +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.progmodel.facets.param.choices.enums;
-
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManagerAware;
-import org.apache.isis.core.metamodel.facetapi.FacetUtil;
-import org.apache.isis.core.metamodel.facetapi.FeatureType;
-import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
-import org.apache.isis.core.metamodel.facets.FacetedMethodParameter;
-import org.apache.isis.core.metamodel.facets.choices.ChoicesFacet;
-import org.apache.isis.core.metamodel.facets.param.choices.ActionParameterChoicesFacet;
-
-public class ParameterChoicesFacetDerivedFromChoicesFacetFacetFactory extends FacetFactoryAbstract implements AdapterManagerAware {
-
- private AdapterManager adapterManager;
-
- public ParameterChoicesFacetDerivedFromChoicesFacetFacetFactory() {
- super(FeatureType.PARAMETERS_ONLY);
- }
-
- @Override
- public void processParams(final ProcessParameterContext processParameterContext) {
- final Class<?> paramType = processParameterContext.getMethod().getParameterTypes()[processParameterContext.getParamNum()];
-
- if(!getSpecificationLoader().loadSpecification(paramType).containsDoOpFacet(ChoicesFacet.class)) {
- return;
- }
-
- // don't trample over any existing facets.
- final FacetedMethodParameter facetHolder = processParameterContext.getFacetHolder();
- if(facetHolder.containsDoOpFacet(ActionParameterChoicesFacet.class)) {
- return;
- }
-
- FacetUtil.addFacet(new ActionParameterChoicesFacetDerivedFromChoicesFacet(facetHolder, getSpecificationLoader(), getAdapterManager()));
- }
-
- // /////////////////////////////////////////////
- // Injected
- // /////////////////////////////////////////////
-
- protected AdapterManager getAdapterManager() {
- return adapterManager;
- }
-
- @Override
- public void setAdapterManager(final AdapterManager adapterManager) {
- this.adapterManager = adapterManager;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/choices/method/ActionChoicesFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/choices/method/ActionChoicesFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/choices/method/ActionChoicesFacetFactory.java
deleted file mode 100644
index 42b4868..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/choices/method/ActionChoicesFacetFactory.java
+++ /dev/null
@@ -1,115 +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.progmodel.facets.param.choices.method;
-
-import java.lang.reflect.Method;
-import java.util.Collection;
-
-import org.apache.isis.core.commons.lang.StringExtensions;
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManagerAware;
-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.methodutils.MethodScope;
-import org.apache.isis.core.progmodel.facets.MethodFinderUtils;
-import org.apache.isis.core.progmodel.facets.MethodPrefixBasedFacetFactoryAbstract;
-import org.apache.isis.core.progmodel.facets.MethodPrefixConstants;
-
-public class ActionChoicesFacetFactory extends MethodPrefixBasedFacetFactoryAbstract implements AdapterManagerAware {
-
- private static final String[] PREFIXES = { MethodPrefixConstants.CHOICES_PREFIX };
-
- private AdapterManager adapterManager;
-
- /**
- * Note that the {@link Facet}s registered are the generic ones from
- * noa-architecture (where they exist)
- */
- public ActionChoicesFacetFactory() {
- super(FeatureType.ACTIONS_ONLY, OrphanValidation.VALIDATE, PREFIXES);
- }
-
- // ///////////////////////////////////////////////////////
- // Actions
- // ///////////////////////////////////////////////////////
-
- @Override
- public void process(final ProcessMethodContext processMethodContext) {
- attachActionChoicesFacetIfParameterChoicesMethodIsFound(processMethodContext);
- }
-
- private void attachActionChoicesFacetIfParameterChoicesMethodIsFound(final ProcessMethodContext processMethodContext) {
-
- final Method actionMethod = processMethodContext.getMethod();
- final Class<?>[] actionParamTypes = actionMethod.getParameterTypes();
-
- if (actionParamTypes.length <= 0) {
- return;
- }
-
- Method choicesMethod = null;
- if (choicesMethod == null) {
- choicesMethod = findChoicesMethodReturning(processMethodContext, Object[][].class);
- }
- if (choicesMethod == null) {
- choicesMethod = findChoicesMethodReturning(processMethodContext, Object[].class);
- }
- if (choicesMethod == null) {
- choicesMethod = findChoicesMethodReturning(processMethodContext, Collection.class);
- }
- if (choicesMethod == null) {
- return;
- }
- processMethodContext.removeMethod(choicesMethod);
-
- final Class<?> returnType = actionMethod.getReturnType();
- final FacetHolder action = processMethodContext.getFacetHolder();
- final ActionChoicesFacetViaMethod facet = new ActionChoicesFacetViaMethod(choicesMethod, returnType, action, getSpecificationLoader(), getAdapterManager());
- FacetUtil.addFacet(facet);
- }
-
- protected Method findChoicesMethodReturning(final ProcessMethodContext processMethodContext, final Class<?> returnType2) {
- Method choicesMethod;
- final Class<?> cls = processMethodContext.getCls();
-
- final Method actionMethod = processMethodContext.getMethod();
- final MethodScope methodScope = MethodScope.scopeFor(actionMethod);
- final String capitalizedName = StringExtensions.asCapitalizedName(actionMethod.getName());
-
- final String name = MethodPrefixConstants.CHOICES_PREFIX + capitalizedName;
- choicesMethod = MethodFinderUtils.findMethod(cls, methodScope, name, returnType2, new Class[0]);
- return choicesMethod;
- }
-
- // ///////////////////////////////////////////////////////////////
- // Dependencies
- // ///////////////////////////////////////////////////////////////
-
- @Override
- public void setAdapterManager(final AdapterManager adapterMap) {
- this.adapterManager = adapterMap;
- }
-
- protected AdapterManager getAdapterManager() {
- return adapterManager;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/choices/method/ActionChoicesFacetViaMethod.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/choices/method/ActionChoicesFacetViaMethod.java b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/choices/method/ActionChoicesFacetViaMethod.java
deleted file mode 100644
index 628dca3..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/choices/method/ActionChoicesFacetViaMethod.java
+++ /dev/null
@@ -1,115 +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.progmodel.facets.param.choices.method;
-
-import java.lang.reflect.Method;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.isis.core.commons.lang.ObjectExtensions;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
-import org.apache.isis.core.metamodel.adapter.util.AdapterInvokeUtils;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.ImperativeFacet;
-import org.apache.isis.core.metamodel.facets.actions.choices.ActionChoicesFacetAbstract;
-import org.apache.isis.core.metamodel.spec.DomainModelException;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.SpecificationLoader;
-import org.apache.isis.core.progmodel.facets.CollectionUtils;
-
-public class ActionChoicesFacetViaMethod extends ActionChoicesFacetAbstract implements ImperativeFacet {
-
- private final Method method;
- private final Class<?> choicesType;
- private final SpecificationLoader specificationLookup;
- private final AdapterManager adapterMap;
-
- public ActionChoicesFacetViaMethod(final Method method, final Class<?> choicesType, final FacetHolder holder, final SpecificationLoader specificationLookup, final AdapterManager adapterManager) {
- super(holder);
- this.method = method;
- this.choicesType = choicesType;
- this.specificationLookup = specificationLookup;
- this.adapterMap = adapterManager;
- }
-
- /**
- * Returns a singleton list of the {@link Method} provided in the
- * constructor.
- */
- @Override
- public List<Method> getMethods() {
- return Collections.singletonList(method);
- }
-
- @Override
- public Intent getIntent(final Method method) {
- return Intent.CHOICES_OR_AUTOCOMPLETE;
- }
-
- @Override
- public boolean impliesResolve() {
- return true;
- }
-
- @Override
- public boolean impliesObjectChanged() {
- return false;
- }
-
- @Override
- public Object[][] getChoices(final ObjectAdapter owningAdapter) {
- final Object invoke = AdapterInvokeUtils.invoke(method, owningAdapter);
- if (!(invoke instanceof Object[])) {
- throw new DomainModelException("Expected an array of collections (Object[]) containing choices for all parameters, but got " + invoke + " instead. Perhaps the parameter number is missing!");
- }
- final Object[] options = (Object[]) invoke;
- final Object[][] results = new Object[options.length][];
- for (int i = 0; i < results.length; i++) {
- if (options[i] == null) {
- results[i] = null;
- } else if (options[i].getClass().isArray()) {
- results[i] = ObjectExtensions.asArray(options[i]);
- } else {
- final ObjectSpecification specification = getSpecificationLookup().loadSpecification(choicesType);
- results[i] = CollectionUtils.getCollectionAsObjectArray(options[i], specification, getAdapterMap());
- }
- }
- return results;
- }
-
- @Override
- protected String toStringValues() {
- return "method=" + method + ",type=" + choicesType;
- }
-
- // ///////////////////////////////////////////////////////
- // Dependencies
- // ///////////////////////////////////////////////////////
-
- private SpecificationLoader getSpecificationLookup() {
- return specificationLookup;
- }
-
- private AdapterManager getAdapterMap() {
- return adapterMap;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/choices/methodnum/ActionParameterChoicesFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/choices/methodnum/ActionParameterChoicesFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/choices/methodnum/ActionParameterChoicesFacetFactory.java
deleted file mode 100644
index bc46ce6..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/choices/methodnum/ActionParameterChoicesFacetFactory.java
+++ /dev/null
@@ -1,160 +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.progmodel.facets.param.choices.methodnum;
-
-import java.lang.reflect.Array;
-import java.lang.reflect.Method;
-import java.util.Collection;
-import java.util.List;
-
-import org.apache.isis.core.commons.lang.ListExtensions;
-import org.apache.isis.core.commons.lang.StringExtensions;
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManagerAware;
-import org.apache.isis.core.metamodel.exceptions.MetaModelException;
-import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.facetapi.FacetUtil;
-import org.apache.isis.core.metamodel.facetapi.FeatureType;
-import org.apache.isis.core.metamodel.facets.FacetedMethod;
-import org.apache.isis.core.metamodel.facets.FacetedMethodParameter;
-import org.apache.isis.core.metamodel.facets.FacetFactory.ProcessMethodContext;
-import org.apache.isis.core.metamodel.facets.actions.choices.ActionChoicesFacet;
-import org.apache.isis.core.metamodel.methodutils.MethodScope;
-import org.apache.isis.core.progmodel.facets.MethodFinderUtils;
-import org.apache.isis.core.progmodel.facets.MethodPrefixBasedFacetFactoryAbstract;
-import org.apache.isis.core.progmodel.facets.MethodPrefixConstants;
-
-public class ActionParameterChoicesFacetFactory extends MethodPrefixBasedFacetFactoryAbstract implements AdapterManagerAware {
-
- private static final String[] PREFIXES = {};
-
- private AdapterManager adapterManager;
-
- /**
- * Note that the {@link Facet}s registered are the generic ones from
- * noa-architecture (where they exist)
- */
- public ActionParameterChoicesFacetFactory() {
- super(FeatureType.ACTIONS_ONLY, OrphanValidation.VALIDATE, PREFIXES);
- }
-
- // ///////////////////////////////////////////////////////
- // Actions
- // ///////////////////////////////////////////////////////
-
- @Override
- public void process(final ProcessMethodContext processMethodContext) {
-
- final FacetedMethod facetedMethod = processMethodContext.getFacetHolder();
- final List<FacetedMethodParameter> holderList = facetedMethod.getParameters();
-
- attachChoicesFacetForParametersIfChoicesNumMethodIsFound(processMethodContext, holderList);
-
- }
-
- private void attachChoicesFacetForParametersIfChoicesNumMethodIsFound(final ProcessMethodContext processMethodContext, final List<FacetedMethodParameter> parameters) {
-
- if (parameters.isEmpty()) {
- return;
- }
-
- final Method actionMethod = processMethodContext.getMethod();
- final Class<?>[] paramTypes = actionMethod.getParameterTypes();
-
- for (int i = 0; i < paramTypes.length; i++) {
-
- final Class<?> arrayOfParamType = (Array.newInstance(paramTypes[i], 0)).getClass();
-
- final Method choicesMethod = findChoicesNumMethodReturning(processMethodContext, i);
- if (choicesMethod == null) {
- continue;
- }
-
- processMethodContext.removeMethod(choicesMethod);
-
- final FacetedMethod facetedMethod = processMethodContext.getFacetHolder();
- if (facetedMethod.containsDoOpFacet(ActionChoicesFacet.class)) {
- final Class<?> cls = processMethodContext.getCls();
- throw new MetaModelException(cls + " uses both old and new choices syntax - must use one or other");
- }
-
- // add facets directly to parameters, not to actions
- final FacetedMethodParameter paramAsHolder = parameters.get(i);
- FacetUtil.addFacet(new ActionParameterChoicesFacetViaMethod(choicesMethod, arrayOfParamType, paramAsHolder, getSpecificationLoader(), getAdapterManager()));
- }
- }
-
- /**
- * search successively for the default method, trimming number of param types each loop
- */
- private static Method findChoicesNumMethodReturning(final ProcessMethodContext processMethodContext, final int n) {
-
- final Method actionMethod = processMethodContext.getMethod();
- final List<Class<?>> paramTypes = ListExtensions.mutableCopy(actionMethod.getParameterTypes());
-
- final Class<?> arrayOfParamType = (Array.newInstance(paramTypes.get(n), 0)).getClass();
-
- final int numParamTypes = paramTypes.size();
-
- for(int i=0; i< numParamTypes+1; i++) {
- Method method;
-
- method = findChoicesNumMethodReturning(processMethodContext, n, paramTypes.toArray(new Class<?>[]{}), arrayOfParamType);
- if(method != null) {
- return method;
- }
- method = findChoicesNumMethodReturning(processMethodContext, n, paramTypes.toArray(new Class<?>[]{}), Collection.class);
- if(method != null) {
- return method;
- }
-
- // remove last, and search again
- if(!paramTypes.isEmpty()) {
- paramTypes.remove(paramTypes.size()-1);
- }
- }
-
- return null;
- }
-
-
-
- private static Method findChoicesNumMethodReturning(final ProcessMethodContext processMethodContext, final int n, Class<?>[] paramTypes, final Class<?> returnType) {
- final Class<?> cls = processMethodContext.getCls();
- final Method actionMethod = processMethodContext.getMethod();
- final String capitalizedName = StringExtensions.asCapitalizedName(actionMethod.getName());
- final String name = MethodPrefixConstants.CHOICES_PREFIX + n + capitalizedName;
- return MethodFinderUtils.findMethod(cls, MethodScope.OBJECT, name, returnType, paramTypes);
- }
-
- // ///////////////////////////////////////////////////////////////
- // Dependencies
- // ///////////////////////////////////////////////////////////////
-
- @Override
- public void setAdapterManager(final AdapterManager adapterManager) {
- this.adapterManager = adapterManager;
- }
-
- private AdapterManager getAdapterManager() {
- return adapterManager;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/choices/methodnum/ActionParameterChoicesFacetViaMethod.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/choices/methodnum/ActionParameterChoicesFacetViaMethod.java b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/choices/methodnum/ActionParameterChoicesFacetViaMethod.java
deleted file mode 100644
index 3024ad4..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/choices/methodnum/ActionParameterChoicesFacetViaMethod.java
+++ /dev/null
@@ -1,92 +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.progmodel.facets.param.choices.methodnum;
-
-import java.lang.reflect.Method;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.isis.core.commons.lang.ObjectExtensions;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
-import org.apache.isis.core.metamodel.adapter.util.AdapterInvokeUtils;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.ImperativeFacet;
-import org.apache.isis.core.metamodel.facets.ImperativeFacet.Intent;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.SpecificationLoader;
-import org.apache.isis.core.progmodel.facets.CollectionUtils;
-import org.apache.isis.core.progmodel.facets.param.choices.ActionParameterChoicesFacetAbstract;
-
-public class ActionParameterChoicesFacetViaMethod extends ActionParameterChoicesFacetAbstract implements ImperativeFacet {
-
- private final Method method;
- private final Class<?> choicesType;
-
- public ActionParameterChoicesFacetViaMethod(final Method method, final Class<?> choicesType, final FacetHolder holder, final SpecificationLoader specificationLookup, final AdapterManager adapterManager) {
- super(holder, specificationLookup, adapterManager);
- this.method = method;
- this.choicesType = choicesType;
- }
-
- /**
- * Returns a singleton list of the {@link Method} provided in the
- * constructor.
- */
- @Override
- public List<Method> getMethods() {
- return Collections.singletonList(method);
- }
-
- @Override
- public Intent getIntent(final Method method) {
- return Intent.CHOICES_OR_AUTOCOMPLETE;
- }
-
- @Override
- public boolean impliesResolve() {
- return true;
- }
-
- @Override
- public boolean impliesObjectChanged() {
- return false;
- }
-
- @Override
- public Object[] getChoices(final ObjectAdapter adapter, final List<ObjectAdapter> argumentsIfAvailable) {
- final Object choices = AdapterInvokeUtils.invokeAutofit(method, adapter, argumentsIfAvailable, getAdapterManager());
- if (choices == null) {
- return new Object[0];
- }
- if (choices.getClass().isArray()) {
- return ObjectExtensions.asArray(choices);
- } else {
- final ObjectSpecification specification = getSpecification(choicesType);
- return CollectionUtils.getCollectionAsObjectArray(choices, specification, getAdapterManager());
- }
- }
-
- @Override
- protected String toStringValues() {
- return "method=" + method + ",type=" + choicesType;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/defaults/ActionParameterDefaultsFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/defaults/ActionParameterDefaultsFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/defaults/ActionParameterDefaultsFacetAbstract.java
deleted file mode 100644
index eb0f8a0..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/defaults/ActionParameterDefaultsFacetAbstract.java
+++ /dev/null
@@ -1,37 +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.progmodel.facets.param.defaults;
-
-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.facets.param.defaults.ActionParameterDefaultsFacet;
-
-public abstract class ActionParameterDefaultsFacetAbstract extends FacetAbstract implements ActionParameterDefaultsFacet {
-
- public static Class<? extends Facet> type() {
- return ActionParameterDefaultsFacet.class;
- }
-
- public ActionParameterDefaultsFacetAbstract(final FacetHolder holder) {
- super(type(), holder, Derivation.NOT_DERIVED);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/defaults/ActionParameterDefaultsFacetNone.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/defaults/ActionParameterDefaultsFacetNone.java b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/defaults/ActionParameterDefaultsFacetNone.java
deleted file mode 100644
index 6800f48..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/defaults/ActionParameterDefaultsFacetNone.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.progmodel.facets.param.defaults;
-
-import java.util.List;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-
-public class ActionParameterDefaultsFacetNone extends ActionParameterDefaultsFacetAbstract {
-
- public ActionParameterDefaultsFacetNone(final FacetHolder holder) {
- super(holder);
- }
-
- @Override
- public Object getDefault(final ObjectAdapter inObject, List<ObjectAdapter> parameters) {
- return null;
- }
-
- @Override
- public boolean isNoop() {
- return true;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/defaults/fromtype/ActionParameterDefaultFacetDerivedFromTypeFacets.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/defaults/fromtype/ActionParameterDefaultFacetDerivedFromTypeFacets.java b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/defaults/fromtype/ActionParameterDefaultFacetDerivedFromTypeFacets.java
deleted file mode 100644
index a7523a9..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/defaults/fromtype/ActionParameterDefaultFacetDerivedFromTypeFacets.java
+++ /dev/null
@@ -1,54 +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.progmodel.facets.param.defaults.fromtype;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.actions.defaults.ActionDefaultsFacetAbstract;
-import org.apache.isis.core.progmodel.facets.object.defaults.DefaultedFacet;
-
-public class ActionParameterDefaultFacetDerivedFromTypeFacets extends ActionDefaultsFacetAbstract {
-
- private final DefaultedFacet[] defaultedFacets;
-
- public ActionParameterDefaultFacetDerivedFromTypeFacets(final DefaultedFacet[] defaultedFacets, final FacetHolder holder) {
- super(holder, Derivation.DERIVED);
- this.defaultedFacets = defaultedFacets;
- }
-
- /**
- * Return the defaults.
- *
- * <p>
- * Note that we get the defaults fresh each time in case the defaults might
- * conceivably change.
- */
- @Override
- public Object[] getDefaults(final ObjectAdapter inObject) {
- final Object[] defaults = new Object[defaultedFacets.length];
- for (int i = 0; i < defaults.length; i++) {
- if (defaultedFacets[i] != null) {
- defaults[i] = defaultedFacets[i].getDefault();
- }
- }
- return defaults;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/defaults/fromtype/ParameterDefaultDerivedFromTypeFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/defaults/fromtype/ParameterDefaultDerivedFromTypeFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/defaults/fromtype/ParameterDefaultDerivedFromTypeFacetFactory.java
deleted file mode 100644
index 97c4629..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/defaults/fromtype/ParameterDefaultDerivedFromTypeFacetFactory.java
+++ /dev/null
@@ -1,65 +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.progmodel.facets.param.defaults.fromtype;
-
-import org.apache.isis.core.metamodel.facetapi.FacetUtil;
-import org.apache.isis.core.metamodel.facetapi.FeatureType;
-import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
-import org.apache.isis.core.metamodel.facets.actions.defaults.ActionDefaultsFacet;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.progmodel.facets.object.defaults.DefaultedFacet;
-
-public class ParameterDefaultDerivedFromTypeFacetFactory extends FacetFactoryAbstract {
-
- public ParameterDefaultDerivedFromTypeFacetFactory() {
- super(FeatureType.PARAMETERS_ONLY);
- }
-
- /**
- * If there is a {@link DefaultedFacet} on any of the action's parameter
- * types, then installs a {@link ActionDefaultsFacet} for the action.
- */
- @Override
- public void processParams(final ProcessParameterContext processParameterContext) {
- // don't overwrite any defaults already picked up
- if (processParameterContext.getFacetHolder().getFacet(ActionDefaultsFacet.class) != null) {
- return;
- }
-
- // try to infer defaults from any of the parameter's underlying types
- final Class<?>[] parameterTypes = processParameterContext.getMethod().getParameterTypes();
- final DefaultedFacet[] parameterTypeDefaultedFacets = new DefaultedFacet[parameterTypes.length];
- boolean hasAtLeastOneDefault = false;
- for (int i = 0; i < parameterTypes.length; i++) {
- final Class<?> paramType = parameterTypes[i];
- parameterTypeDefaultedFacets[i] = getDefaultedFacet(paramType);
- hasAtLeastOneDefault = hasAtLeastOneDefault | (parameterTypeDefaultedFacets[i] != null);
- }
- if (hasAtLeastOneDefault) {
- FacetUtil.addFacet(new ActionParameterDefaultFacetDerivedFromTypeFacets(parameterTypeDefaultedFacets, processParameterContext.getFacetHolder()));
- }
- }
-
- private DefaultedFacet getDefaultedFacet(final Class<?> paramType) {
- final ObjectSpecification paramTypeSpec = getSpecificationLoader().loadSpecification(paramType);
- return paramTypeSpec.getFacet(DefaultedFacet.class);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/defaults/methodnum/ActionParameterDefaultsFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/defaults/methodnum/ActionParameterDefaultsFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/defaults/methodnum/ActionParameterDefaultsFacetFactory.java
deleted file mode 100644
index b8efc34..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/defaults/methodnum/ActionParameterDefaultsFacetFactory.java
+++ /dev/null
@@ -1,148 +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.progmodel.facets.param.defaults.methodnum;
-
-import java.lang.reflect.Method;
-import java.util.List;
-
-import org.apache.isis.core.commons.lang.ListExtensions;
-import org.apache.isis.core.commons.lang.StringExtensions;
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManagerAware;
-import org.apache.isis.core.metamodel.exceptions.MetaModelException;
-import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.facetapi.FacetUtil;
-import org.apache.isis.core.metamodel.facetapi.FeatureType;
-import org.apache.isis.core.metamodel.facets.FacetedMethod;
-import org.apache.isis.core.metamodel.facets.FacetedMethodParameter;
-import org.apache.isis.core.metamodel.facets.actions.defaults.ActionDefaultsFacet;
-import org.apache.isis.core.metamodel.methodutils.MethodScope;
-import org.apache.isis.core.progmodel.facets.MethodFinderUtils;
-import org.apache.isis.core.progmodel.facets.MethodPrefixBasedFacetFactoryAbstract;
-import org.apache.isis.core.progmodel.facets.MethodPrefixConstants;
-
-/**
- * Sets up all the {@link Facet}s for an action in a single shot.
- */
-public class ActionParameterDefaultsFacetFactory extends MethodPrefixBasedFacetFactoryAbstract implements AdapterManagerAware {
-
- private static final String[] PREFIXES = {};
-
- private AdapterManager adapterManager;
-
- /**
- * Note that the {@link Facet}s registered are the generic ones from
- * noa-architecture (where they exist)
- */
- public ActionParameterDefaultsFacetFactory() {
- super(FeatureType.ACTIONS_ONLY, OrphanValidation.VALIDATE, PREFIXES);
- }
-
- // ///////////////////////////////////////////////////////
- // Actions
- // ///////////////////////////////////////////////////////
-
- @Override
- public void process(final ProcessMethodContext processMethodContext) {
-
- final FacetedMethod facetedMethod = processMethodContext.getFacetHolder();
- final List<FacetedMethodParameter> holderList = facetedMethod.getParameters();
-
- attachDefaultFacetForParametersIfDefaultsNumMethodIsFound(processMethodContext, holderList);
- }
-
- private void attachDefaultFacetForParametersIfDefaultsNumMethodIsFound(final ProcessMethodContext processMethodContext, final List<FacetedMethodParameter> parameters) {
-
- if (parameters.isEmpty()) {
- return;
- }
-
- final Method actionMethod = processMethodContext.getMethod();
- final Class<?>[] paramTypes = actionMethod.getParameterTypes();
-
- for (int i = 0; i < paramTypes.length; i++) {
-
- // attempt to match method...
- Method defaultMethod = findDefaultNumMethod(processMethodContext, i);
- if (defaultMethod == null) {
- continue;
- }
-
- processMethodContext.removeMethod(defaultMethod);
-
- final FacetedMethod facetedMethod = processMethodContext.getFacetHolder();
- if (facetedMethod.containsDoOpFacet(ActionDefaultsFacet.class)) {
- final Class<?> cls2 = processMethodContext.getCls();
- throw new MetaModelException(cls2 + " uses both old and new default syntax for " + actionMethod.getName() + "(...) - must use one or other");
- }
-
- // add facets directly to parameters, not to actions
- final FacetedMethodParameter paramAsHolder = parameters.get(i);
- FacetUtil.addFacet(new ActionParameterDefaultsFacetViaMethod(defaultMethod, paramAsHolder, getAdapterManager()));
- }
- }
-
- /**
- * search successively for the default method, trimming number of param types each loop
- */
- private static Method findDefaultNumMethod(ProcessMethodContext processMethodContext, int n) {
-
- final Method actionMethod = processMethodContext.getMethod();
- final List<Class<?>> paramTypes = ListExtensions.mutableCopy(actionMethod.getParameterTypes());
-
- final int numParamTypes = paramTypes.size();
-
- for(int i=0; i< numParamTypes+1; i++) {
- final Method method = findDefaultNumMethod(processMethodContext, n, paramTypes.toArray(new Class<?>[]{}));
- if(method != null) {
- return method;
- }
- // remove last, and search again
- if(!paramTypes.isEmpty()) {
- paramTypes.remove(paramTypes.size()-1);
- }
- }
-
- return null;
- }
-
- private static Method findDefaultNumMethod(final ProcessMethodContext processMethodContext, int n, Class<?>[] paramTypes) {
- final Class<?> cls = processMethodContext.getCls();
- final Method actionMethod = processMethodContext.getMethod();
- final Class<?> returnType = actionMethod.getParameterTypes()[n];
- final String capitalizedName = StringExtensions.asCapitalizedName(actionMethod.getName());
- return MethodFinderUtils.findMethod(cls, MethodScope.OBJECT, MethodPrefixConstants.DEFAULT_PREFIX + n + capitalizedName, returnType, paramTypes);
- }
-
- // ///////////////////////////////////////////////////////////////
- // Dependencies
- // ///////////////////////////////////////////////////////////////
-
- @Override
- public void setAdapterManager(final AdapterManager adapterManager) {
- this.adapterManager = adapterManager;
- }
-
- private AdapterManager getAdapterManager() {
- return adapterManager;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/defaults/methodnum/ActionParameterDefaultsFacetViaMethod.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/defaults/methodnum/ActionParameterDefaultsFacetViaMethod.java b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/defaults/methodnum/ActionParameterDefaultsFacetViaMethod.java
deleted file mode 100644
index 0f573eb..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/defaults/methodnum/ActionParameterDefaultsFacetViaMethod.java
+++ /dev/null
@@ -1,89 +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.progmodel.facets.param.defaults.methodnum;
-
-import java.lang.reflect.Method;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
-import org.apache.isis.core.metamodel.adapter.util.AdapterInvokeUtils;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.ImperativeFacet;
-import org.apache.isis.core.metamodel.facets.ImperativeFacet.Intent;
-import org.apache.isis.core.progmodel.facets.param.defaults.ActionParameterDefaultsFacetAbstract;
-
-public class ActionParameterDefaultsFacetViaMethod extends ActionParameterDefaultsFacetAbstract implements ImperativeFacet {
-
- private final Method method;
- private final AdapterManager adapterManager;
-
- public ActionParameterDefaultsFacetViaMethod(final Method method, final FacetHolder holder, final AdapterManager adapterManager) {
- super(holder);
- this.method = method;
- this.adapterManager = adapterManager;
- }
-
- /**
- * Returns a singleton list of the {@link Method} provided in the
- * constructor.
- */
- @Override
- public List<Method> getMethods() {
- return Collections.singletonList(method);
- }
-
- @Override
- public Intent getIntent(final Method method) {
- return Intent.DEFAULTS;
- }
-
- @Override
- public boolean impliesResolve() {
- return true;
- }
-
- @Override
- public boolean impliesObjectChanged() {
- return false;
- }
-
- @Override
- public Object getDefault(final ObjectAdapter target, List<ObjectAdapter> argumentsIfAvailable) {
- return AdapterInvokeUtils.invokeAutofit(method, target, argumentsIfAvailable, getAdapterManager());
- }
-
-
-
- @Override
- protected String toStringValues() {
- return "method=" + method;
- }
-
- // /////////////////////////////////////////////////////////
- // Dependencies
- // /////////////////////////////////////////////////////////
-
- protected AdapterManager getAdapterManager() {
- return adapterManager;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/describedas/annotation/DescribedAsAnnotationOnParameterFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/describedas/annotation/DescribedAsAnnotationOnParameterFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/describedas/annotation/DescribedAsAnnotationOnParameterFacetFactory.java
deleted file mode 100644
index cc6e86d..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/describedas/annotation/DescribedAsAnnotationOnParameterFacetFactory.java
+++ /dev/null
@@ -1,71 +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.progmodel.facets.param.describedas.annotation;
-
-import java.lang.annotation.Annotation;
-
-import org.apache.isis.applib.annotation.DescribedAs;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facetapi.FacetUtil;
-import org.apache.isis.core.metamodel.facetapi.FeatureType;
-import org.apache.isis.core.metamodel.facets.Annotations;
-import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
-import org.apache.isis.core.metamodel.facets.describedas.DescribedAsFacet;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-
-public class DescribedAsAnnotationOnParameterFacetFactory extends FacetFactoryAbstract {
-
- public DescribedAsAnnotationOnParameterFacetFactory() {
- super(FeatureType.PARAMETERS_ONLY);
- }
-
- @Override
- public void processParams(final ProcessParameterContext processParameterContext) {
-
- final int paramNum = processParameterContext.getParamNum();
- final Class<?> parameterType = processParameterContext.getMethod().getParameterTypes()[paramNum];
- final Annotation[] parameterAnnotations = Annotations.getParameterAnnotations(processParameterContext.getMethod())[paramNum];
- for (final Annotation parameterAnnotation : parameterAnnotations) {
- if (parameterAnnotation instanceof DescribedAs) {
- FacetUtil.addFacet(create((DescribedAs) parameterAnnotation, processParameterContext.getFacetHolder()));
- return;
- }
- }
-
- // otherwise, fall back to a description on the parameter's type, if
- // available
- final DescribedAsFacet parameterTypeDescribedAsFacet = getDescribedAsFacet(parameterType);
- if (parameterTypeDescribedAsFacet != null) {
- FacetUtil.addFacet(new DescribedAsFacetForParameterDerivedFromType(parameterTypeDescribedAsFacet, processParameterContext.getFacetHolder()));
- return;
- }
-
- }
-
- private DescribedAsFacet create(final DescribedAs annotation, final FacetHolder holder) {
- return annotation == null ? null : new DescribedAsFacetAnnotationOnParameter(annotation.value(), holder);
- }
-
- private DescribedAsFacet getDescribedAsFacet(final Class<?> type) {
- final ObjectSpecification paramTypeSpec = getSpecificationLoader().loadSpecification(type);
- return paramTypeSpec.getFacet(DescribedAsFacet.class);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/describedas/annotation/DescribedAsFacetAnnotationOnParameter.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/describedas/annotation/DescribedAsFacetAnnotationOnParameter.java b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/describedas/annotation/DescribedAsFacetAnnotationOnParameter.java
deleted file mode 100644
index f265dad..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/describedas/annotation/DescribedAsFacetAnnotationOnParameter.java
+++ /dev/null
@@ -1,31 +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.progmodel.facets.param.describedas.annotation;
-
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.describedas.DescribedAsFacetAbstract;
-
-public class DescribedAsFacetAnnotationOnParameter extends DescribedAsFacetAbstract {
-
- public DescribedAsFacetAnnotationOnParameter(final String value, final FacetHolder holder) {
- super(value, holder);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/describedas/annotation/DescribedAsFacetForParameterDerivedFromType.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/describedas/annotation/DescribedAsFacetForParameterDerivedFromType.java b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/describedas/annotation/DescribedAsFacetForParameterDerivedFromType.java
deleted file mode 100644
index 3f9ceab..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/describedas/annotation/DescribedAsFacetForParameterDerivedFromType.java
+++ /dev/null
@@ -1,32 +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.progmodel.facets.param.describedas.annotation;
-
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.describedas.DescribedAsFacet;
-import org.apache.isis.core.metamodel.facets.describedas.DescribedAsFacetAbstract;
-
-public class DescribedAsFacetForParameterDerivedFromType extends DescribedAsFacetAbstract {
-
- public DescribedAsFacetForParameterDerivedFromType(final DescribedAsFacet describedAsFacet, final FacetHolder holder) {
- super(describedAsFacet.value(), holder);
- }
-
-}