@Override public FieldEntryBuilder use(FieldType fieldType) { this.id = fieldType.getId(); return this; }
@Override public SchemaId getFieldDependency() { return fieldType.getId(); }
@Override public FieldEntryBuilder name(QName name) throws RepositoryException, InterruptedException { this.id = typeManager.getFieldTypeByName(name).getId(); return this; }
@Override public FieldEntryBuilder name(String name) throws RepositoryException, InterruptedException { this.id = typeManager.getFieldTypeByName(resolveNamespace(name)).getId(); return this; }
public SchemaId getLastVTag() throws RepositoryException, InterruptedException { if (lastVTag == null) { lastVTag = typeManager.getFieldTypeByName(VersionTag.LAST).getId(); } return lastVTag; }
@Override public SchemaId getFieldDependency() { if (follows.get(0) instanceof LinkFieldFollow) { return ((LinkFieldFollow) follows.get(0)).getFieldType().getId(); } else { // A follow-variant is like a link to another document, but the link can never change as the // identity of the document never changes. Therefore, there is no dependency on a field. return null; } }
public FieldType registerFieldType(SchemaId fieldId, TypeManager typeMgr) throws Exception { for (FieldType entry : fields) { if (entry.getId().equals(fieldId)) { return entry; } } FieldType fieldType = typeMgr.getFieldTypeById(fieldId); fields.add(fieldType); return fieldType; }
public static Map<Scope, Set<SchemaId>> getFieldTypeIdsAndScope(Set<SchemaId> fieldIds, FieldFilter fieldFilter, TypeManager typeManager) throws RepositoryException, InterruptedException { Map<Scope, Set<SchemaId>> result = new HashMap<Scope, Set<SchemaId>>(); Map<Scope, Set<FieldType>> fieldTypesByScope = getFieldTypeAndScope(fieldIds, fieldFilter, typeManager); for (Scope scope: fieldTypesByScope.keySet()) { Set<SchemaId> schemaIds = new HashSet<SchemaId>(); for (FieldType t: fieldTypesByScope.get(scope)) { schemaIds.add(t.getId()); } result.put(scope, schemaIds); } return result; }
public Object eval(Record record, FieldType fieldType, TypeManager typeManager) throws RepositoryException, InterruptedException { return fieldsById.get(fieldType.getId()).eval(record, typeManager); }
@Override public FieldType createOrUpdateFieldType(FieldType fieldType) throws RepositoryException, InterruptedException { if (fieldType.getId() == null) { fieldType.setId(new SchemaIdImpl(UUID.randomUUID())); } fieldTypesByName.put(fieldType.getName(), fieldType); fieldTypes.put(fieldType.getId(), fieldType); return fieldType; }
@Override public FieldEntryBuilder name(String namespace, String name) throws RepositoryException, InterruptedException { this.id = typeManager.getFieldTypeByName(new QName(namespace, name)).getId(); return this; }
@Override public FieldEntryBuilder createOrUpdate() throws RepositoryException, InterruptedException { FieldType fieldType = typeManager.createOrUpdateFieldType(buildFieldType()); FieldEntryBuilderImpl.this.id = fieldType.getId(); return FieldEntryBuilderImpl.this; } }
@Override public FieldEntryBuilder create() throws RepositoryException, InterruptedException { FieldType fieldType = typeManager.createFieldType(buildFieldType()); FieldEntryBuilderImpl.this.id = fieldType.getId(); return FieldEntryBuilderImpl.this; }
public synchronized void updateFieldType(FieldType fieldType) throws TypeException, InterruptedException { super.updateFieldType(fieldType); triggerRefresh(fieldType.getId().getBytes(), false); }
public Set<SchemaId> getModifiedVTags() throws RepositoryException, InterruptedException { Set<SchemaId> changedVTags = VersionTag.filterVTagFields(event.getUpdatedFields(), typeManager); // Last vtag if (event.getVersionCreated() != -1 || event.getType() == CREATE) { changedVTags.add(typeManager.getFieldTypeByName(VersionTag.LAST).getId()); } return changedVTags; } }
private void addField(FieldType type, Object oldValue, Object newValue, RecordEvent.IndexRecordFilterData idxSel) throws RepositoryException, InterruptedException { if (oldValue == null && newValue == null) { return; } if (oldValue != null) { oldValue = type.getValueType().toBytes(oldValue, new IdentityRecordStack()); } if (newValue != null) { newValue = type.getValueType().toBytes(newValue, new IdentityRecordStack()); } idxSel.addChangedField(type.getId(), (byte[])oldValue, (byte[])newValue); }
private void checkImmutableFieldsCorrespond(FieldType userFieldType, FieldType latestFieldType) throws FieldTypeUpdateException { if (!userFieldType.getValueType().equals(latestFieldType.getValueType())) { throw new FieldTypeUpdateException("Changing the valueType of a fieldType '" + latestFieldType.getId() + "' (current name: " + latestFieldType.getName() + ") is not allowed; old '" + latestFieldType.getValueType() + "' new '" + userFieldType.getValueType() + "'"); } if (!userFieldType.getScope().equals(latestFieldType.getScope())) { throw new FieldTypeUpdateException("Changing the scope of a fieldType '" + latestFieldType.getId() + "' (current name: " + latestFieldType.getName() + ") is not allowed; old '" + latestFieldType.getScope() + "' new '" + userFieldType.getScope() + "'"); } }
public static ObjectNode toJson(FieldType fieldType, Namespaces namespaces, boolean includeName) { ObjectNode fieldNode = JsonNodeFactory.instance.objectNode(); fieldNode.put("id", fieldType.getId().toString()); if (includeName) { fieldNode.put("name", QNameConverter.toJson(fieldType.getName(), namespaces)); } fieldNode.put("scope", fieldType.getScope().toString().toLowerCase()); fieldNode.put("valueType", ValueTypeNSConverter.toJson(fieldType.getValueType().getName(), namespaces)); return fieldNode; } }
private static void printFieldType(Pair<FieldTypeEntry, FieldType> pair, PrintStream out, int indent) { FieldTypeEntry fieldTypeEntry = pair.getV1(); FieldType fieldType = pair.getV2(); println(out, indent, "Name = " + fieldType.getName()); println(out, indent, "ID = " + fieldType.getId()); println(out, indent, "Mandatory = " + fieldTypeEntry.isMandatory()); try { println(out, indent, "ValueType = " + fieldType.getValueType().getName()); } catch (Throwable t) { // value type failed to load } }
public AvroFieldType convert(FieldType fieldType) { AvroFieldType avroFieldType = new AvroFieldType(); avroFieldType.setId(convert(fieldType.getId())); avroFieldType.setName(convert(fieldType.getName())); avroFieldType.setValueType(convert(fieldType.getValueType())); avroFieldType.setScope(convert(fieldType.getScope())); return avroFieldType; }