Beispiel #1
0
 @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;
 }
Beispiel #2
0
 @Override
 public String parseAndValidate(
     final ScalarModel scalarModel, final String proposedPojoAsStr) {
   final OneToOneAssociation property = scalarModel.getPropertyMemento().getProperty();
   ParseableFacet parseableFacet = property.getFacet(ParseableFacet.class);
   if (parseableFacet == null) {
     parseableFacet = property.getSpecification().getFacet(ParseableFacet.class);
   }
   try {
     final ObjectAdapter parentAdapter =
         scalarModel.parentObjectAdapterMemento.getObjectAdapter(ConcurrencyChecking.CHECK);
     final ObjectAdapter currentValue = property.get(parentAdapter);
     Localization localization = IsisContext.getLocalization();
     final ObjectAdapter proposedAdapter =
         parseableFacet.parseTextEntry(currentValue, proposedPojoAsStr, localization);
     final Consent valid = property.isAssociationValid(parentAdapter, proposedAdapter);
     return valid.isAllowed() ? null : valid.getReason();
   } catch (final ConcurrencyException ex) {
     // disregard concurrency exceptions because will pick up at the IFormValidator level
     // rather
     // than each individual property.
     return null;
   } catch (final Exception ex) {
     return ex.getLocalizedMessage();
   }
 }