@Override public Object eval(Record record, TypeManager typeManager) { // Special about the version field is that it can evaluate to null, while normal fields // will never be null. Or should we rather throw a FieldNotFoundException when its null? return record.getVersion(); } },
@Override public Long getVersion() { return delegate.getVersion(); }
@Override public Long getVersion() { return record.getVersion(); }
@Override public Record update(Record record, boolean updateVersion, boolean useLastRecordType) throws RepositoryException, InterruptedException { if (updateVersion) { Long version = record.getVersion(); if (version == null) { version = 0L; } } record = writeRecord(record); return record; } private Record merge(Record record, Record original) {
/** * Removes any versioned information from the supplied record object. */ public static void reduceToNonVersioned(Record record, Set<QName> fields, TypeManager typeManager) throws RepositoryException, InterruptedException { if (record.getVersion() == null) { // The record has no versions so there should be no versioned fields in it return; } Iterator<Map.Entry<QName, Object>> fieldsIt = record.getFields().entrySet().iterator(); while (fieldsIt.hasNext()) { Map.Entry<QName, Object> entry = fieldsIt.next(); if (fields != null && !fields.contains(entry.getKey())) { fieldsIt.remove(); } else if (typeManager.getFieldTypeByName(entry.getKey()).getScope() != Scope.NON_VERSIONED) { fieldsIt.remove(); } } // Remove versioned record type info record.setRecordType(Scope.VERSIONED, (QName) null, null); record.setRecordType(Scope.VERSIONED_MUTABLE, (QName) null, null); }
out.println("Version = " + record.getVersion());
@Override public IdRecord readWithIds(RecordId recordId, Long aLong, List<SchemaId> schemaIds) throws RepositoryException, InterruptedException { Record record = getRecord(recordId); TypeManager typeManager = this.getTypeManager(); Map<SchemaId, QName> map = Maps.newHashMap(); for (QName qname : record.getFields().keySet()) { map.put(typeManager.getFieldTypeByName(qname).getId(), qname); } Map<Scope,SchemaId> recordTypeIds = Maps.newHashMap(); for (Scope scope : Scope.values()) { RecordType recordType = typeManager.getRecordTypeByName(record.getRecordTypeName(scope), record.getVersion()); if (recordType != null) { recordTypeIds.put(scope, recordType.getId()); } } IdRecord idRecord = new IdRecordImpl(record, map, recordTypeIds); return idRecord; }
private Record writeRecord(Record record) throws RepositoryException, InterruptedException{ record = record.cloneRecord(); Record originalRecord = record; ResponseStatus status = ResponseStatus.UP_TO_DATE; if (records.containsKey(record.getId())) { originalRecord = records.get(record.getId()); record = merge(record, originalRecord); if (!originalRecord.equals(record)) { status = ResponseStatus.UPDATED; } } else { status = ResponseStatus.CREATED; } QName recordTypeName = record.getRecordTypeName(); Long recordTypeVersion = getTypeManager().getRecordTypeByName(recordTypeName, null).getVersion(); record.setRecordType(recordTypeName, recordTypeVersion); validateRecord(record, originalRecord, getTypeManager().getRecordTypeByName(recordTypeName, null)); Long version = record.getVersion() == null ? 0l : record.getVersion(); record.setVersion(version + 1); records.put(record.getId(), record.cloneRecord()); record.setResponseStatus(status); return record; }
|| changedScopes.contains(Scope.VERSIONED_MUTABLE); if (!versionedFieldsHaveChanged) { version = originalRecord.getVersion();
if (record.getVersion() != null) { recordNode.put("version", record.getVersion());
writeNullOrVLong(record.getVersion(), output);
clearData(recordId, originalRecord, originalRecord.getVersion());
Set<BlobReference> referencedBlobs = new HashSet<BlobReference>(); Set<BlobReference> unReferencedBlobs = new HashSet<BlobReference>(); long newVersion = originalRecord.getVersion() == null ? 1 : originalRecord.getVersion() + 1;
Long newVersion = newRecord.getVersion(); if (newVersion != null) { recordEvent.setVersionCreated(newVersion);
Long version = record.getVersion(); if (version == null) { throw new InvalidRecordException("The version of the record cannot be null to update mutable fields",
break; case UPDATED: importListener.updated(EntityType.RECORD, null, record.getId().toString(), record.getVersion()); break; case CANNOT_CREATE_EXISTS: