@Override public T inspect( T record, Connection conn, SQLDialect dialect ) throws MetadataInspectorException { List<SchemaValidationEvent> errors = validate( record.getAsOMElement() ); if ( errors.isEmpty() ) { return record; } else { StringBuilder sb = new StringBuilder(); for ( SchemaValidationEvent error : errors ) { sb.append( error ); sb.append( "\n" ); } String msg = Messages.getMessage( "ERROR_VALIDATE" + sb ); LOG.debug( msg ); throw new MetadataInspectorException( msg ); } } }
@Override public List<String> performInsert( InsertOperation insert ) throws MetadataStoreException, MetadataInspectorException { List<String> identifierList = new ArrayList<String>(); for ( MetadataRecord record : insert.getRecords() ) { try { for ( RecordInspector<ISORecord> r : inspectors ) { record = r.inspect( (ISORecord) record, conn, dialect ); } if ( record != null ) { ISORecord rec = new ISORecord( record.getAsOMElement() ); TransactionService transactionService = getTransactionalSqlService(); transactionService.executeInsert( conn, rec ); identifierList.add( rec.getIdentifier() ); } } catch ( XMLStreamException e ) { e.printStackTrace(); throw new MetadataStoreException( "Error on insert: " + e.getMessage(), e ); } } return identifierList; }
inspectorChain.add( new MetadataSchemaValidationInspector<ISORecord>() );
ISORecord record = (ISORecord) update.getRecord(); for ( RecordInspector<ISORecord> r : inspectors ) { record = r.inspect( record, conn, dialect ); ISORecord record = (ISORecord) update.getRecord(); for ( RecordInspector<ISORecord> r : inspectors ) { record = r.inspect( record, conn, dialect ); rec = inspector.inspect( rec, conn, dialect );