@Override public int performUpdate( UpdateOperation update ) throws MetadataStoreException, MetadataInspectorException { try { if ( update.getRecordProperty() != null && !update.getRecordProperty().isEmpty() ) { throw new MetadataStoreException( "Update failed: update of properties is not implemented yet!" ); } List<ISORecord> records = storedRecords.getRecords( update.getConstraint() ); if ( records.size() > 1 ) { throw new MetadataStoreException( "Update failed: update with a filter matching more than one record is not implemented yet!" ); } if ( records.size() == 0 ) { return 0; } ISORecord record = records.get( 0 ); transactionCandidates.add( new TransactionCandidate( TransactionStatus.UPDATE, record.getIdentifier(), (ISORecord) update.getRecord() ) ); return 1; } catch ( FilterEvaluationException e ) { LOG.error( "Could not evaluate filter!", e ); throw new MetadataStoreException( 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 int performDelete( DeleteOperation delete ) throws MetadataStoreException { List<ISORecord> recordsToDelete; try { recordsToDelete = storedRecords.getRecords( delete.getConstraint() ); for ( ISORecord record : recordsToDelete ) { transactionCandidates.add( new TransactionCandidate( TransactionStatus.DELETE, record.getIdentifier(), record ) ); } } catch ( FilterEvaluationException e ) { LOG.error( "Could not evaluate filter!", e ); throw new MetadataStoreException( e ); } return recordsToDelete.size(); }
int result = 0; if ( update.getRecord() != null && update.getConstraint() == null ) { LOG.warn( "Update with complete metadatset and without constraint is deprecated. Updating is forwarded, the fileIdentifer is used to find the record to update." ); ISORecord record = (ISORecord) update.getRecord(); for ( RecordInspector<ISORecord> r : inspectors ) { record = r.inspect( record, conn, dialect ); MetadataQuery query = new MetadataQuery( null, null, (OperatorFilter) update.getConstraint(), null, 1, Integer.MIN_VALUE ); boolean updated = false; if ( update.getRecord() != null ) { ISORecord record = (ISORecord) update.getRecord(); for ( RecordInspector<ISORecord> r : inspectors ) { record = r.inspect( record, conn, dialect ); } else if ( update.getConstraint() != null && ( update.getRecordProperty() != null && update.getRecordProperty().size() > 0 ) ) { List<MetadataProperty> recordProperty = update.getRecordProperty(); for ( MetadataProperty metadataProperty : recordProperty ) { ValueReference name = metadataProperty.getPropertyName(); Object value = metadataProperty.getReplacementValue();
handle = getNodeAsString( transChildElement, new XPath( "@handle", nsContext ), null ); operations.add( new InsertOperation( records, typeName, handle ) ); break; operations.add( new DeleteOperation( handle, typeName, constraintDelete ) ); break; throw new InvalidParameterValueException( msg ); recordProperty = new MetadataProperty( new ValueReference( name.trim(), nsContext ), value ); recordProperties.add( recordProperty ); throw new InvalidParameterValueException( msg ); operations.add( new UpdateOperation( handle, newRecord, typeName, parseConstraint( constraintElement ), recordProperties ) ); break;
null ); Filter constraint = new OperatorFilter( new PropertyIsEqualTo( propertyName, lit, true, null ) ); trans.performDelete( new DeleteOperation( null, null, constraint ) ); List<String> performInsert = trans.performInsert( new InsertOperation( Collections.singletonList( profile ), null, null ) );
@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<? 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; }
@Override public int performDelete( DeleteOperation delete ) throws MetadataStoreException { try { // TODO: mapping! ISOPropertyNameMapper mapping = new ISOPropertyNameMapper( dialect, queryables ); AbstractWhereBuilder builder = dialect.getWhereBuilder( mapping, (OperatorFilter) delete.getConstraint(), null, false ); TransactionService transactionService = getTransactionalSqlService(); return transactionService.executeDelete( conn, builder ); } catch ( Exception e ) { throw new MetadataStoreException( e.getMessage() ); } }
@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; }
throws MetadataStoreException { Filter constraint = operation.getConstraint();