Ejemplo n.º 1
0
 private static <T extends Facet> T getFacet(Class<T> facetType, FacetHolder... holders) {
   for (FacetHolder holder : holders) {
     if (holder == null) {
       continue;
     }
     final T facet = holder.getFacet(facetType);
     if (facet != null) {
       return facet;
     }
   }
   return null;
 }
  public static PublishedActionFacet create(
      final Action action, final IsisConfiguration configuration, final FacetHolder holder) {

    final Publishing publishing = action != null ? action.publishing() : Publishing.AS_CONFIGURED;

    switch (publishing) {
      case AS_CONFIGURED:
        final PublishActionsConfiguration setting =
            PublishActionsConfiguration.parse(configuration);
        switch (setting) {
          case NONE:
            return null;
          case IGNORE_SAFE:
            final ActionSemanticsFacet actionSemanticsFacet =
                holder.getFacet(ActionSemanticsFacet.class);
            if (actionSemanticsFacet == null) {
              throw new IllegalStateException("Require ActionSemanticsFacet in order to process");
            }

            if (actionSemanticsFacet.value().isSafeInNature()) {
              return null;
            }
            // else fall through
          default:
            final PublishingPayloadFactoryForAction publishingPayloadFactory =
                newPayloadFactory(action);
            return action != null
                ? new PublishedActionFacetForActionAnnotation(publishingPayloadFactory, holder)
                : new PublishedActionFacetFromConfiguration(publishingPayloadFactory, holder);
        }
      case DISABLED:
        return null;
      case ENABLED:
        return new PublishedActionFacetForActionAnnotation(newPayloadFactory(action), holder);
    }
    return null;
  }
Ejemplo n.º 3
0
 @Override
 public <T extends Facet> T getFacet(Class<T> cls) {
   return facetHolder.getFacet(cls);
 }
Ejemplo n.º 4
0
 static boolean isRequired(final FacetHolder facetHolder) {
   final MandatoryFacet mandatoryFacet = facetHolder.getFacet(MandatoryFacet.class);
   final boolean required = mandatoryFacet != null && !mandatoryFacet.isInvertedSemantics();
   return required;
 }
Ejemplo n.º 5
0
 @Override
 public <T extends Facet> T getFacet(final ScalarModel scalarModel, final Class<T> facetType) {
   final FacetHolder facetHolder = scalarModel.getParameterMemento().getActionParameter();
   return facetHolder.getFacet(facetType);
 }
Ejemplo n.º 6
0
 @Override
 public <T extends Facet> T getFacet(final ScalarModel scalarModel, final Class<T> facetType) {
   final FacetHolder facetHolder = scalarModel.getPropertyMemento().getProperty();
   return facetHolder.getFacet(facetType);
 }
Ejemplo n.º 7
0
 private boolean isAlwaysHidden(final FacetHolder holder) {
   final HiddenFacet hiddenFacet = holder.getFacet(HiddenFacet.class);
   return hiddenFacet != null
       && hiddenFacet.when() == When.ALWAYS
       && hiddenFacet.where() == Where.ANYWHERE;
 }