private void showInvalidConversionDialog(ConversionException ce) { JOptionPane.showMessageDialog( currentWindow(), this.getInvalidInputMessage(ce.getClassToConvertTo()), resourceRepository().getString("CONVERSION_VALUE_DIALOG.ILLEGAL_FORMAT_DIALOG.title"), JOptionPane.WARNING_MESSAGE); }
/** INTERNAL: Get a value from the object and set that in the respective field of the row. */ @Override public Object valueFromObject(Object object, DatabaseField field, AbstractSession session) { // First check if the value can be obtained from the value holder's row. AbstractRecord referenceRow = getIndirectionPolicy().extractReferenceRow(getAttributeValueFromObject(object)); if (referenceRow != null) { Object value = referenceRow.get(field); // Must ensure the classification to get a cache hit. try { value = session.getDatasourcePlatform().convertObject(value, getFieldClassification(field)); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(this, getDescriptor(), e); } return value; } // 2.5.1.6 PWK. added to support batch reading on variable one to ones Object referenceObject = getRealAttributeValueFromObject(object, session); String queryKeyName = (String) getSourceToTargetQueryKeyNames().get(field); ClassDescriptor objectDescriptor = session.getDescriptor(referenceObject.getClass()); DatabaseField targetField = objectDescriptor.getObjectBuilder().getTargetFieldForQueryKeyName(queryKeyName); if (targetField == null) { return null; } return objectDescriptor .getObjectBuilder() .extractValueFromObjectForField(referenceObject, targetField, session); }
/** INTERNAL: Return the implementor for a specified type */ protected Object getImplementorForType(Object type, AbstractSession session) { if (type == null) { return getTypeIndicatorTranslation().get(Helper.getNullWrapper()); } // Must ensure the type is the same, i.e. Integer != BigDecimal. try { type = session.getDatasourcePlatform().convertObject(type, getTypeField().getType()); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(this, getDescriptor(), e); } return getTypeIndicatorTranslation().get(type); }
public void verify() throws Exception { if (m_exception.getErrorCode() != ConversionException.COULD_NOT_BE_CONVERTED_EXTENDED) { throw new TestErrorException("Invalid conversion exception was thrown"); } }