@Override public Integer getScale(ScalarModel scalarModel) { final ActionParameterMemento parameterMemento = scalarModel.getParameterMemento(); final ObjectActionParameter actionParameter = parameterMemento.getActionParameter(); final BigDecimalValueFacet facet = actionParameter.getFacet(BigDecimalValueFacet.class); return facet != null ? facet.getScale() : null; }
@Override public String getLongName(final ScalarModel scalarModel) { final ObjectAdapterMemento adapterMemento = scalarModel.getObjectAdapterMemento(); if (adapterMemento == null) { // shouldn't happen return null; } ObjectSpecId objectSpecId = adapterMemento.getObjectSpecId(); final String specShortName = SpecUtils.getSpecificationFor(objectSpecId).getShortIdentifier(); final String parmId = scalarModel .getParameterMemento() .getActionParameter() .getIdentifier() .toNameIdentityString(); return specShortName + "-" + parmId + "-" + scalarModel.getParameterMemento().getNumber(); }
@Override public int getAutoCompleteOrChoicesMinLength(ScalarModel scalarModel) { if (scalarModel.hasAutoComplete()) { final ActionParameterMemento parameterMemento = scalarModel.getParameterMemento(); final ObjectActionParameter actionParameter = parameterMemento.getActionParameter(); return actionParameter.getAutoCompleteMinLength(); } else { return 0; } }
@Override public List<ObjectAdapter> getChoices( final ScalarModel scalarModel, final ObjectAdapter[] argumentsIfAvailable) { final ActionParameterMemento parameterMemento = scalarModel.getParameterMemento(); final ObjectActionParameter actionParameter = parameterMemento.getActionParameter(); final ObjectAdapter[] choices = actionParameter.getChoices( scalarModel.parentObjectAdapterMemento.getObjectAdapter(ConcurrencyChecking.CHECK), argumentsIfAvailable); return choicesAsList(choices); }
@Override public List<ObjectAdapter> getAutoComplete( final ScalarModel scalarModel, final String searchArg) { final ActionParameterMemento parameterMemento = scalarModel.getParameterMemento(); final ObjectActionParameter actionParameter = parameterMemento.getActionParameter(); final ObjectAdapter[] choices = actionParameter.getAutoComplete( scalarModel.parentObjectAdapterMemento.getObjectAdapter( ConcurrencyChecking.NO_CHECK), searchArg); return choicesAsList(choices); }
@Override public String parseAndValidate( final ScalarModel scalarModel, final String proposedPojoAsStr) { final ObjectActionParameter parameter = scalarModel.getParameterMemento().getActionParameter(); ParseableFacet parseableFacet = parameter.getFacet(ParseableFacet.class); if (parseableFacet == null) { parseableFacet = parameter.getSpecification().getFacet(ParseableFacet.class); } try { final ObjectAdapter parentAdapter = scalarModel.parentObjectAdapterMemento.getObjectAdapter(ConcurrencyChecking.CHECK); Localization localization = IsisContext.getLocalization(); final String invalidReasonIfAny = parameter.isValid(parentAdapter, proposedPojoAsStr, localization); return invalidReasonIfAny; } catch (final Exception ex) { return ex.getLocalizedMessage(); } }
@Override public String getDescribedAs(final ScalarModel scalarModel) { final ActionParameterMemento parameterMemento = scalarModel.getParameterMemento(); final ObjectActionParameter actionParameter = parameterMemento.getActionParameter(); return actionParameter.getDescription(); }
@Override public boolean hasAutoComplete(final ScalarModel scalarModel) { final ActionParameterMemento parameterMemento = scalarModel.getParameterMemento(); final ObjectActionParameter actionParameter = parameterMemento.getActionParameter(); return actionParameter.hasAutoComplete(); }
@Override public <T extends Facet> T getFacet(final ScalarModel scalarModel, final Class<T> facetType) { final FacetHolder facetHolder = scalarModel.getParameterMemento().getActionParameter(); return facetHolder.getFacet(facetType); }
@Override public boolean isRequired(final ScalarModel scalarModel) { final FacetHolder facetHolder = scalarModel.getParameterMemento().getActionParameter(); return isRequired(facetHolder); }
@Override public String getIdentifier(final ScalarModel scalarModel) { return "" + scalarModel.getParameterMemento().getNumber(); }
@Override public ObjectSpecification getScalarTypeSpec(final ScalarModel scalarModel) { return scalarModel.getParameterMemento().getSpecification(); }
@Override public String getName(final ScalarModel scalarModel) { return scalarModel.getParameterMemento().getActionParameter().getName(); }