コード例 #1
0
ファイル: ScalarModel.java プロジェクト: 4DvAnCeBoY/isis
 @Override
 public Integer getScale(ScalarModel scalarModel) {
   final PropertyMemento propertyMemento = scalarModel.getPropertyMemento();
   final OneToOneAssociation property = propertyMemento.getProperty();
   final BigDecimalValueFacet facet = property.getFacet(BigDecimalValueFacet.class);
   return facet != null ? facet.getScale() : null;
 }
コード例 #2
0
ファイル: ScalarModel.java プロジェクト: 4DvAnCeBoY/isis
 @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;
 }
コード例 #3
0
  private void addValue() {
    final ObjectAdapter valueAdapter = objectMember.get(objectAdapter);

    // use the runtime type if we have a value, else the compile time type of the member otherwise
    final ObjectSpecification spec =
        valueAdapter != null ? valueAdapter.getSpecification() : objectMember.getSpecification();

    final ValueFacet valueFacet = spec.getFacet(ValueFacet.class);
    if (valueFacet != null) {
      String format = null;
      final Class<?> specClass = spec.getCorrespondingClass();
      if (specClass == java.math.BigDecimal.class) {
        // look for facet on member, else on the value's spec
        final BigDecimalValueFacet bigDecimalValueFacet =
            getFacet(
                BigDecimalValueFacet.class,
                objectMember,
                valueAdapter != null ? valueAdapter.getSpecification() : null);
        if (bigDecimalValueFacet != null) {
          final Integer precision = bigDecimalValueFacet.getPrecision();
          final Integer scale = bigDecimalValueFacet.getScale();
          format = String.format("big-decimal(%d,%d)", precision, scale);
        }
      } else if (specClass == java.math.BigInteger.class) {
        // TODO: need to extend BigIntegerValueFacet similar to BigDecimalValueFacet
      }
      JsonValueEncoder.appendValueAndFormat(spec, valueAdapter, representation, format);
      return;
    }

    final RenderFacet renderFacet = objectMember.getFacet(RenderFacet.class);
    boolean eagerlyRender =
        renderFacet != null
            && renderFacet.value() == Type.EAGERLY
            && rendererContext.canEagerlyRender(valueAdapter);

    if (valueAdapter == null) {
      representation.mapPut("value", NullNode.getInstance());
    } else {
      final TitleFacet titleFacet = spec.getFacet(TitleFacet.class);
      final String title = titleFacet.title(valueAdapter, rendererContext.getLocalization());

      final LinkBuilder valueLinkBuilder =
          DomainObjectReprRenderer.newLinkToBuilder(rendererContext, Rel.VALUE, valueAdapter)
              .withTitle(title);
      if (eagerlyRender) {
        final DomainObjectReprRenderer renderer =
            new DomainObjectReprRenderer(
                rendererContext, getLinkFollowSpecs(), JsonRepresentation.newMap());
        renderer.with(valueAdapter);
        if (mode.isEventSerialization()) {
          renderer.asEventSerialization();
        }

        valueLinkBuilder.withValue(renderer.render());
      }

      representation.mapPut("value", valueLinkBuilder.build());
    }
  }