Package org.lilyproject.repository.api

Examples of org.lilyproject.repository.api.QName


                } catch (InterruptedException e) {
                    Thread.currentThread().interrupt();
                    throw new RuntimeException(e); // unlikely to occur
                }

                FieldType fieldType = typeManager.newFieldType(valueType, new QName(NS, field.name),
                        Scope.NON_VERSIONED);
                fieldType.setId(schemaId);

                field.setFieldType(fieldType);
View Full Code Here


        // Version tag fields
        //

        lastTag = typeManager.getFieldTypeByName(VersionTag.LAST);

        QName nvTagName = new QName(VersionTag.NAMESPACE, "nonversioned");
        nvTag = typeManager.newFieldType(longValueType, nvTagName, Scope.NON_VERSIONED);
        nvTag = typeManager.createFieldType(nvTag);

        QName liveTagName = new QName(VersionTag.NAMESPACE, "live");
        liveTag = typeManager.newFieldType(longValueType, liveTagName, Scope.NON_VERSIONED);
        liveTag = typeManager.createFieldType(liveTag);

        QName previewTagName = new QName(VersionTag.NAMESPACE, "preview");
        previewTag = typeManager.newFieldType(longValueType, previewTagName, Scope.NON_VERSIONED);
        previewTag = typeManager.createFieldType(previewTag);

        // Note: tag 'last' was renamed to 'latest' because there is now built-in behaviour for the tag named 'last'
        QName lastTagName = new QName(VersionTag.NAMESPACE, "latest");
        latestTag = typeManager.newFieldType(longValueType, lastTagName, Scope.NON_VERSIONED);
        latestTag = typeManager.createFieldType(latestTag);

        //
        // Schema types for the nonversioned test
        //

        QName field1Name = new QName(NS, "nv_field1");
        nvfield1 = typeManager.newFieldType(stringValueType, field1Name, Scope.NON_VERSIONED);
        nvfield1 = typeManager.createFieldType(nvfield1);

        QName field2Name = new QName(NS, "nv_field2");
        nvfield2 = typeManager.newFieldType(stringValueType, field2Name, Scope.NON_VERSIONED);
        nvfield2 = typeManager.createFieldType(nvfield2);

        QName linkField1Name = new QName(NS, "nv_linkfield1");
        nvLinkField1 = typeManager.newFieldType(linkValueType, linkField1Name, Scope.NON_VERSIONED);
        nvLinkField1 = typeManager.createFieldType(nvLinkField1);

        QName linkField2Name = new QName(NS, "nv_linkfield2");
        nvLinkField2 = typeManager.newFieldType(linkValueType, linkField2Name, Scope.NON_VERSIONED);
        nvLinkField2 = typeManager.createFieldType(nvLinkField2);

        nvRecordType1 = typeManager.newRecordType(new QName(NS, "NVRecordType1"));
        addNvFieldTypes(nvRecordType1);
        nvRecordType1 = typeManager.createRecordType(nvRecordType1);

        //
        // Schema types for the versioned test
        //
        QName vfield1Name = new QName(NS2, "v_field1");
        vfield1 = typeManager.newFieldType(stringValueType, vfield1Name, Scope.VERSIONED);
        vfield1 = typeManager.createFieldType(vfield1);

        QName vfield2Name = new QName(NS2, "v_field2");
        vfield2 = typeManager.newFieldType(stringValueType, vfield2Name, Scope.VERSIONED);
        vfield2 = typeManager.createFieldType(vfield2);

        QName vlinkField1Name = new QName(NS2, "v_linkfield1");
        vLinkField1 = typeManager.newFieldType(linkValueType, vlinkField1Name, Scope.VERSIONED);
        vLinkField1 = typeManager.createFieldType(vLinkField1);

        QName vlinkField2Name = new QName(NS2, "v_linkfield2");
        vLinkField2 = typeManager.newFieldType(linkValueType, vlinkField2Name, Scope.VERSIONED);
        vLinkField2 = typeManager.createFieldType(vLinkField2);

        QName vStringMvFieldName = new QName(NS2, "v_string_mv_field");
        vStringMvField = typeManager.newFieldType(stringMvValueType, vStringMvFieldName, Scope.VERSIONED);
        vStringMvField = typeManager.createFieldType(vStringMvField);

        QName vLongFieldName = new QName(NS2, "v_long_field");
        vLongField = typeManager.newFieldType(longValueType, vLongFieldName, Scope.VERSIONED);
        vLongField = typeManager.createFieldType(vLongField);

        QName vBlobFieldName = new QName(NS2, "v_blob_field");
        vBlobField = typeManager.newFieldType(blobValueType, vBlobFieldName, Scope.VERSIONED);
        vBlobField = typeManager.createFieldType(vBlobField);

        QName vBlobMvHierFieldName = new QName(NS2, "v_blob_mv_hier_field");
        vBlobMvHierField = typeManager.newFieldType(blobMvHierValueType, vBlobMvHierFieldName, Scope.VERSIONED);
        vBlobMvHierField = typeManager.createFieldType(vBlobMvHierField);

        QName vBlobNestedFieldName = new QName(NS2, "v_blob_nested_field");
        vBlobNestedField = typeManager.newFieldType(blobNestedValueType, vBlobNestedFieldName, Scope.VERSIONED);
        vBlobNestedField = typeManager.createFieldType(vBlobNestedField);

        QName vDateTimeFieldName = new QName(NS2, "v_datetime_field");
        vDateTimeField = typeManager.newFieldType(dateTimeValueType, vDateTimeFieldName, Scope.VERSIONED);
        vDateTimeField = typeManager.createFieldType(vDateTimeField);

        QName vDateFieldName = new QName(NS2, "v_date_field");
        vDateField = typeManager.newFieldType(dateValueType, vDateFieldName, Scope.VERSIONED);
        vDateField = typeManager.createFieldType(vDateField);

        QName vIntHierFieldName = new QName(NS2, "v_int_hier_field");
        vIntHierField = typeManager.newFieldType(intHierValueType, vIntHierFieldName, Scope.VERSIONED);
        vIntHierField = typeManager.createFieldType(vIntHierField);

        vRecordType1 = typeManager.newRecordType(new QName(NS2, "VRecordType1"));
        addVFieldTypes(vRecordType1);
        vRecordType1 = typeManager.createRecordType(vRecordType1);

        //
        // Schema types for testing last tag
        //
        lastRecordType = typeManager.newRecordType(new QName(NS2, "LastRecordType"));
        lastRecordType.addFieldTypeEntry(vfield1.getId(), false);
        lastRecordType.addFieldTypeEntry(nvfield1.getId(), false);
        lastRecordType = typeManager.createRecordType(lastRecordType);

        //
        // Schema types for testing <match> and <foreach>
        //
        for (int i = 1; i <= 6; i++) {
            typeManager.fieldTypeBuilder().name(new QName(NS, "nvmatch" + i))
                    .scope(Scope.NON_VERSIONED)
                    .type("STRING").create();
            typeManager.fieldTypeBuilder().name(new QName(NS2, "match" + i))
                    .scope(Scope.VERSIONED)
                    .type("STRING").create();
        }
        for (QName name : new QName[]{new QName(NS, "Alpha"), new QName(NS, "Beta"), new QName(NS2, "Alpha"),
                new QName(NS2, "Beta")}) {
            RecordType recordType = typeManager.newRecordType(name);
            addNvFieldTypes(recordType);
            addVFieldTypes(recordType);
            for (int i = 1; i <= 6; i++) {
                recordType
                        .addFieldTypeEntry(typeManager.getFieldTypeByName(new QName(NS, "nvmatch" + i)).getId(), false);
                recordType
                        .addFieldTypeEntry(typeManager.getFieldTypeByName(new QName(NS2, "match" + i)).getId(), false);
            }
            // Link fields
            for (int i = 1; i <= 2; i++) {
                recordType.addFieldTypeEntry(typeManager.getFieldTypeByName(new QName(NS, "nv_linkfield" + i)).getId(),
                        false);
                recordType.addFieldTypeEntry(typeManager.getFieldTypeByName(new QName(NS2, "v_linkfield" + i)).getId(),
                        false);
            }
            typeManager.createRecordType(recordType);
        }
View Full Code Here

        String linkedProductId = "linkedProduct12345";
        RecordId linkedRecordId = repository.getIdGenerator().newRecordId(linkedProductId);

        defaultTable.recordBuilder()
                .id(repository.getIdGenerator().newRecordId(baseProductId))
                .recordType(new QName(NS, "Alpha"))
                .field(nvfield1.getName(), "29485")
                .field(nvLinkField1.getName(), new Link(linkedRecordId))
                .create();

        defaultTable.recordBuilder()
                .id(repository.getIdGenerator().newRecordId(baseProductId,
                        Collections.singletonMap("country", "france")))
                .recordType(new QName(NS, "Alpha"))
                .field(nvfield1.getName(), "louche")
                .field(nvfield2.getName(), "10")
                .create();

        defaultTable.recordBuilder()
                .id(repository.getIdGenerator().newRecordId(baseProductId,
                        Collections.singletonMap("country", "belgium")))
                .recordType(new QName(NS, "Alpha"))
                .field(nvfield1.getName(), "schuimspaan")
                .field(nvfield2.getName(), "11")
                .create();

        defaultTable.recordBuilder()
                .id(linkedRecordId)
                .recordType(new QName(NS, "Alpha"))
                .field(nvfield1.getName(), "12345")
                .create();

        commitIndex();
View Full Code Here

        setExpectedCountsForMatch("match4", 2, 0, 0, 0, 0, 0, 0, 0); // ns:Alpha

        verifyMatchResultCounts();

        // Update non-versioned fields
        updateMatchTestRecords(new QName(NS, "nvmatch1"), "nvmatch1");
        setExpectedCountsForMatch("nvmatch1", 0, 0, 0, 0, 2, 2, 2, 2);
        verifyMatchResultCounts();
        updateMatchTestRecords(new QName(NS, "nvmatch2"), "nvmatch2");
        setExpectedCountsForMatch("nvmatch2", 0, 0, 0, 0, 2, 2, 0, 0);
        verifyMatchResultCounts();
        updateMatchTestRecords(new QName(NS, "nvmatch3"), "nvmatch3");
        setExpectedCountsForMatch("nvmatch3", 0, 0, 0, 0, 2, 0, 2, 0);
        verifyMatchResultCounts();
        updateMatchTestRecords(new QName(NS, "nvmatch4"), "nvmatch4");
        setExpectedCountsForMatch("nvmatch4", 0, 0, 0, 0, 2, 0, 0, 0);
        verifyMatchResultCounts();

        // Update versioned fields
        updateMatchTestRecords(new QName(NS2, "match1"), "match1");
        setExpectedCountsForMatch("match1", 1, 1, 1, 1, 1, 1, 1, 1);
        verifyMatchResultCounts();
        updateMatchTestRecords(new QName(NS2, "match2"), "match2");
        setExpectedCountsForMatch("match2", 1, 1, 0, 0, 1, 1, 0, 0);
        verifyMatchResultCounts();
        updateMatchTestRecords(new QName(NS2, "match3"), "match3");
        setExpectedCountsForMatch("match3", 1, 0, 1, 0, 1, 0, 1, 0);
        verifyMatchResultCounts();
        updateMatchTestRecords(new QName(NS2, "match4"), "match4");
        setExpectedCountsForMatch("match4", 1, 0, 0, 0, 1, 0, 0, 0);
        verifyMatchResultCounts();

        //
        // Test match on field conditions using non versioned fields
        // Note: the lines marked with /*hasfield*/ test for a feature we don't support yet, hence commented out
        //
        defaultTable.recordBuilder().id("match_nvfield")
                .recordType(new QName(NS, "Alpha"))
                .field(nvfield1.getName(), "jupiter")
                .field(nvfield2.getName(), "pancake")
                .field(previewTag.getName(), new Long(0))
                .create();

        commitIndex();

        /*hasfield*/// verifyResultCount("nvmatch5:jupiter", 2); // vfield2 is present
        verifyResultCount("nvmatch6:jupiter", 2); // nvfield2=specialvalue

        defaultTable.recordBuilder().id("match_nvfield")
                .field(nvfield1.getName(), "waffle")
                .update();

        commitIndex();

        verifyResultCount("nvmatch6:jupiter", 0); // nvfield2=specialvalue

        /*hasfield*/// verifyResultCount("nvmatch5:jupiter", 2); // nvfield2 is present
        /*hasfield*/// Record record = repository.read(repository.getIdGenerator().newRecordId("match_nvfield"));
        /*hasfield*/// record.delete(nvfield2.getName(), true);

        /*hasfield*/// commitIndex();
        /*hasfield*/// verifyResultCount("nvmatch5:jupiter", 0); // nvfield2 is present
        /*hasfield*/// verifyResultCount("nvmatch6:jupiter", 0); // nvfield2=specialvalue

        //
        // Test match on field conditions (has field, field equals) using non versioned fields
        //
        defaultTable.recordBuilder().id("match_vfield")
                .recordType(new QName(NS, "Alpha"))
                .field(vfield1.getName(), "apollo")
                .field(vfield2.getName(), "bacon")
                .field(previewTag.getName(), new Long(1))
                .create();

        commitIndex();
        /*hasfield*/// verifyResultCount("match5:apollo", 2); // vfield2 is present
        verifyResultCount("match6:apollo", 2); // vfield2=specialvalue

        defaultTable.recordBuilder().id("match_vfield")
                .field(vfield1.getName(), "eggs")
                .update();

        commitIndex();

        /*hasfield*/// verifyResultCount("match5:apollo", 2); // vfield2 is present in preview and last
        verifyResultCount("match6:apollo", 1); // vfield2=specialvalue (version tagged with preview still matches)

        /*hasfield*/// record = repository.read(repository.getIdGenerator().newRecordId("match_vfield"));
        /*hasfield*/// record.delete(vfield2.getName(), true);

        /*hasfield*/// commitIndex();
        /*hasfield*/// verifyResultCount("match5:apollo", 1); // vfield2 is present
        /*hasfield*/// verifyResultCount("match6:apollo", 1); // vfield2=specialvalue

        //
        // TODO: match on variant properties
        //
        for (String lang : new String[]{"en", "fr"}) {
            defaultTable.recordBuilder().id("match_varprops_cupid", vprops("lang", lang))
                    .recordType(new QName(NS, "Alpha"))
                    .field(vfield1.getName(), "cupido_" + lang + "_nobranch")
                    .create();

            defaultTable.recordBuilder().id("match_varprops_merc", vprops("lang", lang))
                    .recordType(new QName(NS, "Alpha"))
                    .field(nvfield1.getName(), "mercurius_" + lang + "_nobranch")
                    .create();

            for (String branch : new String[]{"dev", "prod"}) {
                defaultTable.recordBuilder().id("match_varprops_cupid", vprops("lang", lang, "branch", branch))
                        .recordType(new QName(NS, "Alpha"))
                        .field(vfield1.getName(), "cupido_" + lang + "_" + branch)
                        .create();
                defaultTable.recordBuilder().id("match_varprops_merc", vprops("lang", lang, "branch", branch))
                        .recordType(new QName(NS, "Alpha"))
                        .field(nvfield1.getName(), "mercurius_" + lang + "_" + branch)
                        .create();
            }
        }
        commitIndex();
View Full Code Here

    }

    private void createMatchTestRecord(String ns, String name, String id) throws Exception {
        RecordBuilder builder = defaultTable.recordBuilder();

        builder.recordType(new QName(ns, name))
                .id(id);

        for (int i = 1; i <= 4; i++) {
            builder.field(new QName(NS2, "match" + i), id + "_" + "match" + i + "_orig");
            builder.field(new QName(NS, "nvmatch" + i), id + "_" + "nvmatch" + i + "_orig");
        }
        builder.field(previewTag.getName(), new Long(1));

        builder.create();
    }
View Full Code Here

        ValueType mvStringValueType = typeManager.getValueType("LIST<STRING>");
        ValueType hierStringValueType = typeManager.getValueType("PATH<STRING>");
        ValueType dateValueType = typeManager.getValueType("DATE");
        ValueType blobValueType = typeManager.getValueType("BLOB");

        FieldType field1 = typeManager.createFieldType(stringValueType, new QName(DYN_NS1, "field1"), Scope.VERSIONED);

        FieldType field2 = typeManager.createFieldType(stringValueType, new QName(DYN_NS2, "field2"), Scope.VERSIONED);

        FieldType field3 =
                typeManager.createFieldType(stringValueType, new QName(DYN_NS2, "name_field3"), Scope.VERSIONED);

        FieldType field4 =
                typeManager.createFieldType(longValueType, new QName(DYN_NS2, "name_field4"), Scope.VERSIONED);

        FieldType field5 =
                typeManager.createFieldType(mvStringValueType, new QName(DYN_NS2, "name_field5"), Scope.VERSIONED);

        FieldType field6 =
                typeManager.createFieldType(stringValueType, new QName(DYN_NS2, "scope_field6"), Scope.VERSIONED);

        FieldType field7 =
                typeManager.createFieldType(stringValueType, new QName(DYN_NS2, "scope_field7"), Scope.NON_VERSIONED);

        FieldType field8 = typeManager.createFieldType(dateValueType, new QName(DYN_NS2, "field8"), Scope.VERSIONED);

        FieldType field9 =
                typeManager.createFieldType(mvStringValueType, new QName(DYN_NS2, "mv_field9"), Scope.VERSIONED);

        FieldType field10 =
                typeManager.createFieldType(hierStringValueType, new QName(DYN_NS2, "hier_field10"), Scope.VERSIONED);

        FieldType field11 =
                typeManager.createFieldType(stringValueType, new QName(DYN_NS2, "field11"), Scope.VERSIONED_MUTABLE);

        FieldType field12 =
                typeManager.createFieldType(stringValueType, new QName(DYN_NS2, "field12"), Scope.VERSIONED_MUTABLE);

        FieldType field13 = typeManager.createFieldType(blobValueType, new QName(DYN_NS2, "field13"), Scope.VERSIONED);

        FieldType field14 = typeManager.createFieldType(blobValueType, new QName(DYN_NS2, "field14"), Scope.VERSIONED);

        RecordType rt = typeManager.newRecordType(new QName(DYN_NS1, "RecordType"));
        // It's not necessary to add the fields
        rt = typeManager.createRecordType(rt);

        changeIndexUpdater("indexerconf_dynfields.xml");
View Full Code Here

        //
        log.debug("Begin test V401");
        ValueType stringValueType = typeManager.getValueType("STRING");
        ValueType linkValueType = typeManager.getValueType("LINK");

        FieldType field1 = typeManager.createFieldType(stringValueType, new QName(NS, "sf_field1"), Scope.VERSIONED);

        FieldType field2 = typeManager.createFieldType(linkValueType, new QName(NS, "sf_field2"), Scope.VERSIONED);

        RecordType supertype1 = typeManager.newRecordType(new QName(NS, "sf_supertype1"));
        supertype1 = typeManager.createRecordType(supertype1);

        RecordType supertype2 = typeManager.newRecordType(new QName(NS, "sf_supertype2"));
        supertype2 = typeManager.createRecordType(supertype2);

        // Create a record type with two versions
        RecordType rt = typeManager.newRecordType(new QName(NS, "sf_rt"));
        rt.addFieldTypeEntry(field1.getId(), false);
        rt.addFieldTypeEntry(field2.getId(), false);
        rt.addSupertype(supertype1.getId());
        rt = typeManager.createRecordType(rt);

        rt.addSupertype(supertype2.getId(), supertype2.getVersion());
        rt = typeManager.updateRecordType(rt);

        RecordType rt2 = typeManager.newRecordType(new QName(NS, "sf_rt2"));
        rt2.addFieldTypeEntry(field1.getId(), false);
        rt2.addFieldTypeEntry(field2.getId(), false);
        rt2 = typeManager.createRecordType(rt2);

        //
View Full Code Here

        //
        // Create schema
        //
        log.debug("Begin test V501");
        FieldType nestedListsField = typeManager.createFieldType(typeManager.getValueType("LIST<LIST<STRING>>"),
                new QName(NS, "cf_nestedlists"), Scope.NON_VERSIONED);

        FieldType recordField = typeManager.createFieldType(typeManager.getValueType("RECORD"),
                new QName(NS, "cf_record"), Scope.NON_VERSIONED);

        FieldType recordListField = typeManager.createFieldType(typeManager.getValueType("LIST<RECORD>"),
                new QName(NS, "cf_recordlist"), Scope.NON_VERSIONED);

        RecordType cfRecordType = typeManager.recordTypeBuilder()
                .name(new QName(NS, "ComplexFieldsRecordType"))
                .field(nestedListsField.getId(), false)
                .field(recordField.getId(), false)
                .field(recordListField.getId(), false)
                .create();
View Full Code Here

        //
        // Create schema
        //
        log.debug("Begin test V601");
        FieldType linkField = typeManager.createFieldType(typeManager.getValueType("LINK"),
                new QName(NS, "link"), Scope.NON_VERSIONED);

        FieldType recordField = typeManager.createFieldType(typeManager.getValueType("RECORD"),
                new QName(NS, "record"), Scope.NON_VERSIONED);

        FieldType record2Field = typeManager.createFieldType(typeManager.getValueType("RECORD"),
                new QName(NS, "record2"), Scope.NON_VERSIONED);

        FieldType stringField = typeManager.createFieldType(typeManager.getValueType("STRING"),
                new QName(NS, "string"), Scope.NON_VERSIONED);

        FieldType recordListField = typeManager.createFieldType(typeManager.getValueType("LIST<RECORD>"),
                new QName(NS, "recordlist"), Scope.NON_VERSIONED);

        RecordType recordType = typeManager.recordTypeBuilder()
                .name(new QName(NS, "RecordType"))
                .field(linkField.getId(), false)
                .field(recordField.getId(), false)
                .field(record2Field.getId(), false)
                .field(stringField.getId(), false)
                .field(recordListField.getId(), false)
View Full Code Here

    public void testParseComplexConfiguration() throws Exception {
        //
        // Create schema
        //
        FieldType stringField = typeManager.createFieldType(typeManager.getValueType("STRING"),
                new QName(NS, "string"), Scope.NON_VERSIONED);

        typeManager.recordTypeBuilder()
                .name(new QName(NS, "ComplexConfiguration"))
                .field(stringField.getId(), false)
                .create();

        changeIndexUpdater("indexerconf_complex_configuration.xml");
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.