@Override boolean insertRecord( OMElement record ) throws Exception { MetadataStoreTransaction trans = metadataStore.acquireTransaction(); try { List<String> performInsert = trans.performInsert( new InsertOperation( Collections.singletonList( MetadataRecordFactory.create( record ) ), null, null ) ); trans.commit(); if ( performInsert.isEmpty() ) return false; return true; } catch ( Exception e ) { trans.rollback(); throw e; } }
@Override public List<String> performInsert( InsertOperation insert ) throws MetadataStoreException, MetadataInspectorException { List<String> identifierList = new ArrayList<String>(); for ( MetadataRecord record : insert.getRecords() ) { if ( record != null ) { // TODO: suppor of other registryObjects RegistryPackage ebrimRecord = new RegistryPackage( record.getAsOMElement() ); // TODO: inspect records insert( ebrimRecord ); identifierList.add( ebrimRecord.getIdentifier() ); } } return identifierList; }
@Override public List<String> performInsert( InsertOperation insert ) throws MetadataStoreException, MetadataInspectorException { List<? extends MetadataRecord> recordsToInsert = insert.getRecords(); List<String> insertedIds = new ArrayList<String>( recordsToInsert.size() ); for ( MetadataRecord record : recordsToInsert ) { ISORecord isoRecord = (ISORecord) record; if ( storedRecords.contains( isoRecord ) ) { throw new MetadataStoreException( "Insert failed: record with identifier " + record.getIdentifier() + " exists." ); } transactionCandidates.add( new TransactionCandidate( TransactionStatus.INSERT, isoRecord.getIdentifier(), isoRecord ) ); insertedIds.add( isoRecord.getIdentifier() ); } return insertedIds; }
trans.performDelete( new DeleteOperation( null, null, constraint ) ); List<String> performInsert = trans.performInsert( new InsertOperation( Collections.singletonList( profile ), null, null ) );
@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; }
handle = getNodeAsString( transChildElement, new XPath( "@handle", nsContext ), null ); operations.add( new InsertOperation( records, typeName, handle ) ); break;