@Override @Deprecated public MixinBuilder use(RecordType recordType) { this.id = recordType.getId(); this.version = recordType.getVersion(); return this; }
@Override @Deprecated public MixinBuilder name(String name) throws RepositoryException, InterruptedException { this.id = typeManager.getRecordTypeByName(resolveNamespace(name), null).getId(); return this; }
@Override public SupertypeBuilder name(String name) throws RepositoryException, InterruptedException { this.id = typeManager.getRecordTypeByName(resolveNamespace(name), null).getId(); return this; }
@Override public SupertypeBuilder name(QName name) throws RepositoryException, InterruptedException { this.id = typeManager.getRecordTypeByName(name, null).getId(); return this; }
@Override public SupertypeBuilder use(RecordType recordType) { this.id = recordType.getId(); this.version = recordType.getVersion(); return this; }
@Override @Deprecated public MixinBuilder name(QName name) throws RepositoryException, InterruptedException { this.id = typeManager.getRecordTypeByName(name, null).getId(); return this; }
private boolean removeFromLocalUpdateBucket(RecordType recordType, String bucketId) { Map<SchemaId, Map<Long, RecordType>> localUpdateBucket = localUpdateBuckets.get(bucketId); if (localUpdateBucket == null) { return false; } Map<Long, RecordType> recordTypesByVersion = localUpdateBucket.get(recordType.getId()); if (recordTypesByVersion == null) { return false; } RecordType localRt = recordTypesByVersion.remove(recordType.getVersion()); return localRt != null; }
@Override @Deprecated public MixinBuilder name(String namespace, String name) throws RepositoryException, InterruptedException { this.id = typeManager.getRecordTypeByName(new QName(namespace, name), null).getId(); return this; }
@Override public RecordType createOrUpdateRecordType(RecordType recordType) throws RepositoryException, InterruptedException { if (recordType.getId() == null) { recordType.setId(new SchemaIdImpl(UUID.randomUUID())); } Long version = recordType.getVersion(); if (version == null) { version = new Long(0l); } recordType.setVersion(version + 1l); recordTypeByName.put(recordType.getName(), recordType); recordTypes.put(recordType.getId(), recordType); return recordType; }
@Override public SupertypeBuilder name(String namespace, String name) throws RepositoryException, InterruptedException { this.id = typeManager.getRecordTypeByName(new QName(namespace, name), null).getId(); return this; }
public synchronized void updateRecordType(RecordType recordType) throws TypeException, InterruptedException { super.updateRecordType(recordType); triggerRefresh(recordType.getId().getBytes(), false); }
private Set<QName> findSubTypes(QName recordTypeName, boolean recursive) throws InterruptedException, RepositoryException { ArgumentValidator.notNull(recordTypeName, "recordTypeName"); RecordType recordType = getRecordTypeByName(recordTypeName, null); Set<SchemaId> result = new HashSet<SchemaId>(); collectSubTypes(recordType.getId(), result, recursive); // Translate schema id's to QName's Set<QName> names = new HashSet<QName>(); for (SchemaId id : result) { try { names.add(getRecordTypeById(id, null).getName()); } catch (RecordTypeNotFoundException e) { // skip, this should only occur in border cases, i.e. the schema is being modified while // this method is called } } return names; }
private Set<QName> findSubTypes(QName recordTypeName, boolean recursive) throws InterruptedException, RepositoryException { ArgumentValidator.notNull(recordTypeName, "recordTypeName"); RecordType recordType = getRecordTypeByName(recordTypeName, null); Set<SchemaId> result = new HashSet<SchemaId>(); collectSubTypes(recordType.getId(), result, recursive); // Translate schema id's to QName's Set<QName> names = new HashSet<QName>(); for (SchemaId id : result) { try { names.add(getRecordTypeById(id, null).getName()); } catch (RecordTypeNotFoundException e) { // skip, this should only occur in border cases, i.e. the schema is being modified while // this method is called } } return names; }
/** * Checks if the given record is an instance of the given record type. This does an "instance of" check, * thus also searches the supertypes for a match. */ public static boolean instanceOf(Record record, SchemaId requestedRecordTypeId, TypeManager typeManager) throws InterruptedException, RepositoryException { if (record.getRecordTypeName() == null) { throw new NullPointerException("record type of record is null"); } RecordType recordType = typeManager.getRecordTypeByName(record.getRecordTypeName(), record.getRecordTypeVersion()); if (recordType.getId().equals(requestedRecordTypeId)) { return true; } // Check the ancestor record types return searchParents(recordType, requestedRecordTypeId, typeManager); }
@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; }
/** * Checks if the given record type is a subtype of another record type, or is equal to it. * * <p>This implementation ignores the version aspect of record types: it always navigates to the latest version * of the supertypes, which might not, but usually will, correspond to reality.</p> */ public static boolean isSubtypeOrEqual(QName subRecordType, QName superRecordType, TypeManager typeManager) throws InterruptedException, RepositoryException { if (subRecordType.equals(superRecordType)) { return true; } // Check the ancestor record types SchemaId superRecordTypeId = typeManager.getRecordTypeByName(superRecordType, null).getId(); RecordType subRecordTypeObject = typeManager.getRecordTypeByName(subRecordType, null); return searchParentsLatestVersion(subRecordTypeObject, superRecordTypeId, typeManager); }
/** * Checks if the given record is an instance of the given record type. This does an "instance of" check, * thus also searches the supertypes for a match. */ public static boolean instanceOf(Record record, QName requestedRecordTypeName, TypeManager typeManager) throws InterruptedException, RepositoryException { if (record.getRecordTypeName() == null) { throw new NullPointerException("record type of record is null"); } if (record.getRecordTypeName().equals(requestedRecordTypeName)) { return true; } // Check the ancestor record types SchemaId searchedRecordType = typeManager.getRecordTypeByName(requestedRecordTypeName, null).getId(); RecordType recordType = typeManager.getRecordTypeByName(record.getRecordTypeName(), record.getRecordTypeVersion()); return searchParents(recordType, searchedRecordType, typeManager); }
private boolean updateName(Put put, RecordType recordType, RecordType latestRecordType) throws TypeException, RepositoryException, InterruptedException { if (!recordType.getName().equals(latestRecordType.getName())) { try { getRecordTypeByName(recordType.getName(), null); throw new TypeException("Changing the name '" + recordType.getName() + "' of a recordType '" + recordType.getId() + "' to a name that already exists is not allowed; old '" + latestRecordType.getName() + "' new '" + recordType.getName() + "'"); } catch (RecordTypeNotFoundException allowed) { } put.add(TypeCf.DATA.bytes, TypeColumn.RECORDTYPE_NAME.bytes, encodeName(recordType.getName())); return true; } return false; }
public static ObjectNode toJson(RecordType recordType, WriteOptions options, Namespaces namespaces, boolean includeName) { ObjectNode rtNode = JsonNodeFactory.instance.objectNode(); rtNode.put("id", recordType.getId().toString()); if (includeName) { rtNode.put("name", QNameConverter.toJson(recordType.getName(), namespaces)); } ArrayNode fieldsNode = rtNode.putArray("fields"); for (FieldTypeEntry entry : recordType.getFieldTypeEntries()) { ObjectNode entryNode = fieldsNode.addObject(); entryNode.put("id", entry.getFieldTypeId().toString()); entryNode.put("mandatory", entry.isMandatory()); } rtNode.put("version", recordType.getVersion()); ArrayNode supertypesNode = rtNode.putArray("supertypes"); for (Map.Entry<SchemaId, Long> supertype : recordType.getSupertypes().entrySet()) { ObjectNode entryNode = supertypesNode.addObject(); entryNode.put("id", supertype.getKey().toString()); entryNode.put("version", supertype.getValue()); } return rtNode; }