[ 
https://issues.apache.org/jira/browse/ISIS-1199?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Dan Haywood updated ISIS-1199:
------------------------------
    Summary: [WON'T FIX] [DOC] Screencast for how facet factories work  (was: 
[DOC] Screencast for how facet factories work)

> [WON'T FIX] [DOC] Screencast for how facet factories work
> ---------------------------------------------------------
>
>                 Key: ISIS-1199
>                 URL: https://issues.apache.org/jira/browse/ISIS-1199
>             Project: Isis
>          Issue Type: Documentation
>          Components: Website and Docs
>    Affects Versions: 1.9.0
>            Reporter: Dan Haywood
>            Priority: Minor
>             Fix For: 2.6.0
>
>
> [ObjectSpecification]->*[ObjectMember]
> [ObjectMember]^-[ObjectProperty]
> [ObjectMember]^-[ObjectCollection]
> [ObjectMember]^-[ObjectAction]
> [ObjectAction]->*[ObjectActionParameter]
> ObjectSpecification someSpec = ...
> NamedFacet f = someSpec.getFacet(NamedFacet.class);
> String name = f.getName();
> DescriptionFacet df = someSpec.getFacet(DescriptionFacet.class);
> String df.getDescription();
> hide / disable / validate
> "see it"   "use it"   "do it"
> HidingInteractionAdvisor
> @Hidden
> @Property(hidden=true)
> hideXxx()
> security
> DisablingInteractionAdvisor
> ValidatingInteractionAdvisor
> List<ObjectSpec> specs = 
> IsisContext.getSpecificationLoader().allSpecifications();
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> package domainapp.app.facets.forbidden;
> import java.util.Arrays;
> import java.util.List;
> import com.google.common.collect.Lists;
> import org.apache.isis.applib.events.ValidityEvent;
> import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
> import org.apache.isis.core.metamodel.facetapi.FacetAbstract;
> import org.apache.isis.core.metamodel.facetapi.FacetHolder;
> import org.apache.isis.core.metamodel.interactions.ActionArgumentContext;
> import 
> org.apache.isis.core.metamodel.interactions.ValidatingInteractionAdvisor;
> import org.apache.isis.core.metamodel.interactions.ValidityContext;
> import org.apache.isis.core.metamodel.spec.ObjectSpecification;
> public class ForbiddenWordsFacet extends FacetAbstract implements 
> ValidatingInteractionAdvisor {
>     private List<String> forbiddenStrings = 
> Lists.newArrayList(Arrays.asList("Fred", "Jones"));
>     public ForbiddenWordsFacet(
>             final FacetHolder holder) {
>         super(ForbiddenWordsFacet.class, holder, Derivation.NOT_DERIVED);
>     }
>     @Override
>     public String invalidates(final ValidityContext<? extends ValidityEvent> 
> ic) {
>         if (!(ic instanceof ActionArgumentContext)) {
>             return null;
>         }
>         final ActionArgumentContext actionArgumentContext = 
> (ActionArgumentContext) ic;
>         ObjectAdapter proposed = actionArgumentContext.getProposed();
>         ObjectSpecification specification = proposed.getSpecification();
>         Class<?> correspondingClass = specification.getCorrespondingClass();
>         if(java.lang.String.class.isAssignableFrom(correspondingClass)) {
>             String proposedStr = (String) proposed.getObject();
>             for (String s : forbiddenStrings) {
>                 if(proposedStr.contains(s)) {
>                     return String.format("Cannot contain '%s'", s);
>                 }
>             }
>         }
>         return null;
>     }
> }
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> package domainapp.app.facets.forbidden;
> 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;
> public class ForbiddenWordsFacetFactory extends FacetFactoryAbstract {
>     public ForbiddenWordsFacetFactory() {
>         super(FeatureType.PARAMETERS_ONLY);
>     }
>     @Override
>     public void processParams(final ProcessParameterContext 
> processParameterContext) {
>         FacetedMethodParameter facetHolder = 
> processParameterContext.getFacetHolder();
>         ForbiddenWordsFacet facet = new ForbiddenWordsFacet(facetHolder);
>         FacetUtil.addFacet(facet);
>     }
> }
> isis.reflector.facets.include=domainapp.app.facets.forbidden.ForbiddenWordsFacetFactory



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to