Package org.lilyproject.repository.api

Examples of org.lilyproject.repository.api.QName


        assertEquals(1, countResults(repository.getScanner(scan)));
    }

    @Test
    public void testScanWithReturnFields() throws Exception {
        FieldType f1 = typeManager.createFieldType("STRING", new QName("ReturnFieldsScan", "f1"), Scope.NON_VERSIONED);
        FieldType f2 = typeManager.createFieldType("STRING", new QName("ReturnFieldsScan", "f2"), Scope.NON_VERSIONED);
        FieldType f3 = typeManager.createFieldType("STRING", new QName("ReturnFieldsScan", "f3"), Scope.NON_VERSIONED);
        FieldType f4 = typeManager.createFieldType("STRING", new QName("ReturnFieldsScan", "f4"), Scope.NON_VERSIONED);

        RecordType rt = typeManager.recordTypeBuilder().defaultNamespace("ReturnFieldsScan").name("rt")
                .fieldEntry().use(f1).add()
                .fieldEntry().use(f2).add()
                .fieldEntry().use(f3).add()
View Full Code Here


     * Tests if record type is set when different settings of returnFields is used.
     */
    @Test
    public void testScanWithReturnFieldsRecordType() throws Exception {
        String ns = "ReturnFieldsScan-RecordType";
        FieldType f1 = typeManager.createFieldType("STRING", new QName(ns, "f1"), Scope.NON_VERSIONED);
        FieldType f2 = typeManager.createFieldType("STRING", new QName(ns, "f2"), Scope.NON_VERSIONED);
        FieldType f3 = typeManager.createFieldType("STRING", new QName(ns, "f3"), Scope.NON_VERSIONED);
        FieldType f4 = typeManager.createFieldType("STRING", new QName(ns, "f4"), Scope.NON_VERSIONED);

        RecordType rt = typeManager.recordTypeBuilder().defaultNamespace(ns).name("rt")
                .fieldEntry().use(f1).add()
                .fieldEntry().use(f2).add()
                .fieldEntry().use(f3).add()
View Full Code Here

    public void testMetadataNotSupportedOnBlobFields() throws Exception {
        String[] types = new String[]{"BLOB", "LIST<BLOB>", "LIST<PATH<BLOB>>"};

        for (int i = 0; i < types.length; i++) {
            FieldType blobField = typeManager
                    .createFieldType("BLOB", new QName("metadata-blob", "blob" + i), Scope.NON_VERSIONED);

            Blob blob = new Blob("text/plain", 5L, "foo");
            OutputStream os = repository.getOutputStream(blob);
            os.write("12345".getBytes());
            os.close();
View Full Code Here

            super(delegate);
        }

        @Override
        public Record create(Record record) throws RepositoryException, InterruptedException {
            record.setField(new QName("ns", "f2"), "foo");
            record = super.create(record);
            return record;
        }
View Full Code Here

    private PartValidator fieldValidator() {
        return new PartValidator() {
            @Override
            public void validate(String template, TemplatePart part) throws NameTemplateException {
                QName field = ((FieldTemplatePart) part).getFieldName();
                if (fieldNames != null && !fieldNames.contains(field)) {
                    throw new NameTemplateException("No such field: " + field, template);
                }
            }
        };
View Full Code Here

    private static void reduceFields(Record record, Set<QName> fieldsToInclude) {
        Iterator<QName> it = record.getFields().keySet().iterator();

        while (it.hasNext()) {
            QName name = it.next();
            if (!fieldsToInclude.contains(name)) {
                it.remove();
            }
        }
    }
View Full Code Here

        // The qualified name can either be specified in Lily-style ("{namespace}name") or
        // in XML-style (prefix:name). In Lily-style, if the "namespace" matches a defined
        // prefix, it is substituted.

        if (qname.startsWith("{")) {
            QName name = QName.fromString(qname);
            String ns = contextEl.lookupNamespaceURI(name.getNamespace());
            if (ns != null) {
                return new QName(ns, name.getName());
            } else {
                return name;
            }
        }

        int colonPos = qname.indexOf(":");
        if (colonPos == -1) {
            throw new IndexerConfException(
                    "Field name is not a qualified name, it should include a namespace prefix: " + qname);
        }

        String prefix = qname.substring(0, colonPos);
        String localName = qname.substring(colonPos + 1);

        String uri = contextEl.lookupNamespaceURI(prefix);
        if (uri == null && !prefixResolvingOptional) {
            throw new IndexerConfException("Prefix does not resolve to a namespace: " + qname);
        }
        if (uri == null) {
            uri = prefix;
        }

        return new QName(uri, localName);
    }
View Full Code Here

            for (int i = 0; i < fieldsToDelete.size(); i++) {
                JsonNode fieldToDelete = fieldsToDelete.get(i);
                if (!fieldToDelete.isTextual()) {
                    throw new JsonFormatException("fieldsToDelete should be an array of strings, encountered: " + fieldToDelete);
                } else {
                    QName qname = QNameConverter.fromJson(fieldToDelete.getTextValue(), namespaces);
                    record.getFieldsToDelete().add(qname);
                }
            }
        }

        ObjectNode attributes = getObject(node, "attributes", null);
        if (attributes != null) {
            Iterator<Map.Entry<String, JsonNode>> it = attributes.getFields();
            while(it.hasNext()) {
                Map.Entry<String, JsonNode> entry = it.next();
                record.getAttributes().put(entry.getKey(), entry.getValue().getTextValue());
            }
        }

        Map<QName, MetadataBuilder> metadataBuilders = null;
        ObjectNode metadata = getObject(node, "metadata", null);
        if (metadata != null) {
            metadataBuilders = new HashMap<QName, MetadataBuilder>();
            Iterator<Map.Entry<String, JsonNode>> it = metadata.getFields();
            while (it.hasNext()) {
                Map.Entry<String, JsonNode> entry = it.next();
                QName qname = QNameConverter.fromJson(entry.getKey(), namespaces);
                MetadataBuilder builder = readMetadata(entry.getValue(), qname);
                metadataBuilders.put(qname, builder);
            }
        }

        ObjectNode metadataToDelete = getObject(node, "metadataToDelete", null);
        if (metadataToDelete != null) {
            if (metadataBuilders == null) {
                metadataBuilders = new HashMap<QName, MetadataBuilder>();
            }

            Iterator<Map.Entry<String, JsonNode>> it = metadataToDelete.getFields();
            while (it.hasNext()) {
                Map.Entry<String, JsonNode> entry = it.next();
                QName qname = QNameConverter.fromJson(entry.getKey(), namespaces);
                MetadataBuilder builder = readMetadataToDelete(entry.getValue(), metadataBuilders.get(qname), qname);
                metadataBuilders.put(qname, builder);
            }
        }
View Full Code Here

        return new QName(uri, localName);
    }

    public static FieldType getFieldType(String qname, Element contextEl, SystemFields systemFields, TypeManager typeManager) throws IndexerConfException, InterruptedException,
            RepositoryException {
        QName parsedQName = parseQName(qname, contextEl);
        return getFieldType(parsedQName, systemFields, typeManager);
    }
View Full Code Here

        Record record = repository.getRecordFactory().newRecord();

        JsonNode typeNode = handle.node.get("type");
        if (typeNode != null) {
            if (typeNode.isObject()) {
                QName qname = QNameConverter.fromJson(JsonUtil.getString(typeNode, "name"), namespaces);
                Long version = JsonUtil.getLong(typeNode, "version", null);
                record.setRecordType(qname, version);
            } else if (typeNode.isTextual()) {
                record.setRecordType(QNameConverter.fromJson(typeNode.getTextValue(), namespaces));
            }
        }

        ObjectNode fields = getObject(handle.node, "fields", null);
        if (fields != null) {
            Iterator<Map.Entry<String, JsonNode>> it = fields.getFields();
            while (it.hasNext()) {
                Map.Entry<String, JsonNode> entry = it.next();

                QName qname = QNameConverter.fromJson(entry.getKey(), namespaces);
                FieldType fieldType = repository.getTypeManager().getFieldTypeByName(qname);
                ValueHandle subHandle = new ValueHandle(fields.get(entry.getKey()), "fields." + entry.getKey(),
                        fieldType.getValueType());
                Object value = readValue(subHandle, context);
                if (value != null) {
View Full Code Here

TOP

Related Classes of org.lilyproject.repository.api.QName

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.