public static void invocationException(final String error, final InvocationTargetException e) { final Throwable targetException = e.getTargetException(); if (targetException instanceof ApplicationException) { // an application exception from the domain code is re-thrown as an // IsisException with same semantics throw new IsisApplicationException(targetException); } if (targetException instanceof RuntimeException) { throw (RuntimeException) targetException; } else { throw new MetaModelException(targetException); } }
@Override protected Object preparedStatementObject(final ObjectAdapter value) { final Object o = value.getObject(); if (o instanceof java.sql.Date) { final java.sql.Date javaSqlDate = (java.sql.Date) value.getObject(); final long millisSinceEpoch = javaSqlDate.getTime(); return new LocalDate(millisSinceEpoch); } else if (o instanceof Date) { final Date asDate = (Date) value.getObject(); return new LocalDate(asDate.getMillisSinceEpoch()); } else { throw new IsisApplicationException("Unimplemented JdbcDateMapper instance type: " + value.getClass().toString()); } }
private void abortTransaction(final Throwable exception) { getTransactionManager().getCurrentTransaction().setAbortCause(new IsisApplicationException(exception)); }
@Override protected ObjectAdapter setFromDBColumn(final Results results, final String columnName, final ObjectAssociation field) { ObjectAdapter restoredValue; final Class<?> correspondingClass = field.getSpecification().getCorrespondingClass(); Object resultObject = results.getObject(columnName); if (resultObject == null) { return null; } if (resultObject.getClass() != correspondingClass) { if (checkIfIsClass(correspondingClass, Integer.class, int.class)) { resultObject = results.getInt(columnName); } else if (checkIfIsClass(correspondingClass, Double.class, double.class)) { resultObject = results.getDouble(columnName); } else if (checkIfIsClass(correspondingClass, Float.class, float.class)) { resultObject = results.getFloat(columnName); } else if (checkIfIsClass(correspondingClass, Short.class, short.class)) { resultObject = results.getShort(columnName); } else if (checkIfIsClass(correspondingClass, Long.class, long.class)) { resultObject = results.getLong(columnName); } else if (checkIfIsClass(correspondingClass, Boolean.class, boolean.class)) { resultObject = results.getBoolean(columnName); } else { throw new IsisApplicationException("Unhandled type: " + correspondingClass.getCanonicalName()); } } restoredValue = IsisContext.getPersistenceSession().getAdapterManager().adapterFor(resultObject); return restoredValue; }