Package org.lilyproject.repository.api

Examples of org.lilyproject.repository.api.FieldType


        testType("recordValueTypeId", "LIST<PATH<RECORD<{testRecordType}recordValueTypeRecordType>>>", Arrays.asList(new HierarchyPath(recordField1, recordField2), new HierarchyPath(recordField1, recordField3)));
    }

    @Test
    public void testLinkType() throws Exception {
        FieldType fieldType1 = typeManager.createFieldType(typeManager.newFieldType(typeManager.getValueType("STRING"), new QName("testLinkType", "field1"), Scope.NON_VERSIONED));
        RecordTypeBuilder rtBuilder = typeManager.recordTypeBuilder();
        RecordType valueTypeRT = rtBuilder.name(new QName("testLinkType", "linkValueTypeRecordType"))
            .field(fieldType1.getId(), false)
            .create();

        testType("recordValueTypeId", "LINK", new Link(idGenerator.newRecordId()));
        testType("recordValueTypeId", "LINK<{testLinkType}linkValueTypeRecordType>", new Link(idGenerator.newRecordId()));
        testType("recordValueTypeId", "LIST<LINK<{testLinkType}linkValueTypeRecordType>>", Arrays.asList(new Link(idGenerator.newRecordId()), new Link(idGenerator.newRecordId())));
View Full Code Here


    private void testType(String name, String valueType,
                    Object fieldValue) throws Exception {
        String testName = name+valueType;
        QName fieldTypeName = new QName("valueTypeTest", testName+"FieldId");
        FieldType fieldType = typeManager.createFieldType(typeManager.newFieldType(typeManager.getValueType(
                        valueType), fieldTypeName, Scope.VERSIONED));
        RecordType recordType = typeManager.newRecordType(new QName("valueTypeTest", testName+"RecordTypeId"));
        recordType.addFieldTypeEntry(typeManager.newFieldTypeEntry(fieldType.getId(), true));
        recordType = typeManager.createRecordType(recordType);

        Record record = repository.newRecord(idGenerator.newRecordId());
        record.setRecordType(recordType.getName(), recordType.getVersion());
        record.setField(fieldType.getName(), fieldValue);
        repository.create(record);

        Record actualRecord = repository.read(record.getId());
        assertEquals(fieldValue, actualRecord.getField(fieldType.getName()));
    }
View Full Code Here

    @Test
    public void testRecordVTTypeInVT() throws Exception {
        String ns = "testRecordVTTypeInVT";
        // Create a fieldType to be used as a field in a record type to be used as the type for a RecordValueType
        FieldType fieldType1 = typeManager.createFieldType(typeManager.newFieldType(typeManager.getValueType("STRING"), new QName(ns, "field1"), Scope.NON_VERSIONED));
        // Create a record type to be used as the type for a RecordValueType
        RecordType rt1 = typeManager.recordTypeBuilder()
            .name(new QName(ns, "rt1"))
            .field(fieldType1.getId(), false)
            .create();

        // Make a RecordValueType with the record type specified
        ValueType recordVT1 = typeManager.getValueType("RECORD<{"+ns+"}rt1>");

        // Create a fieldType with as value type a RecordValueType
        FieldType fieldType2 = typeManager.createFieldType(typeManager.newFieldType(recordVT1, new QName(ns, "field2"), Scope.NON_VERSIONED));
        // Create a recordType with a field of this field type
        RecordType rt2 = typeManager.recordTypeBuilder()
            .name(new QName(ns, "rt2"))
            .field(fieldType2.getId(), false)
            .create();

        // Make a record to be used as field value
        Record recordField = repository.recordBuilder().field(new QName(ns, "field1"), "abc").build();
        // Create a record with a record as field
View Full Code Here

    @Test
    public void testRecordVTNested() throws Exception {
        String ns = "testRecordVTNested";
        // Create a fieldType to be used as a field in a record type to be used as the type for a RecordValueType
        FieldType fieldType1 = typeManager.createFieldType(typeManager.newFieldType(typeManager.getValueType("STRING"), new QName(ns, "field1"), Scope.NON_VERSIONED));
        // Create a record type to be used as the type for a RecordValueType
        RecordType rt1 = typeManager.recordTypeBuilder()
            .name(new QName(ns, "rt1"))
            .field(fieldType1.getId(), false)
            .create();

        // Make a RecordValueType with the record type specified
        ValueType recordVT1 = typeManager.getValueType("RECORD<{"+ns+"}rt1>");

        // Create a fieldType with as value type a RecordValueType
        FieldType fieldType2 = typeManager.createFieldType(typeManager.newFieldType(recordVT1, new QName(ns, "field2"), Scope.NON_VERSIONED));
        // Create a recordType with a field of this field type
        RecordType rt2 = typeManager.recordTypeBuilder()
            .name(new QName(ns, "rt2"))
            .field(fieldType2.getId(), false)
            .create();

        // Create a fieldType with as value type a 'nested' RecordValueType
        ValueType recordVT2 = typeManager.getValueType("RECORD<{"+ns+"}rt2>");
        FieldType fieldType3 = typeManager.createFieldType(typeManager.newFieldType(recordVT2, new QName(ns, "field3"), Scope.NON_VERSIONED));
        RecordType rt3 = typeManager.recordTypeBuilder()
            .name(new QName(ns, "rt3"))
            .field(fieldType3.getId(), false)
            .create();

        // Make nested records
        Record recordField1 = repository.recordBuilder().field(new QName(ns, "field1"), "abc").build();
View Full Code Here

    @Test
    public void testRecordVTTypeInRecord() throws Exception {
        String ns = "testRecordVTTypeInRecord";
        // Create a fieldType to be used as a field in a record type to be used as the type for a RecordValueType
        FieldType fieldType1 = typeManager.createFieldType(typeManager.newFieldType(typeManager.getValueType("STRING"), new QName(ns, "field1"), Scope.NON_VERSIONED));
        // Create a record type to be used as the type for a RecordValueType
        RecordType rt1 = typeManager.recordTypeBuilder().name(new QName(ns, "rt1")).field(fieldType1.getId(), false).create();

        // Create record types to be used as versioned and versioned-mutable record types, which should be ignored
        RecordType vrt = typeManager.recordTypeBuilder().name(new QName(ns, "vrt")).field(fieldType1.getId(), false).create();
        RecordType vmrt = typeManager.recordTypeBuilder().name(new QName(ns, "vmrt")).field(fieldType1.getId(), false).create();

        // Make a RecordValueType without the record type specified
        ValueType recordVT1 = typeManager.getValueType("RECORD");

        // Create a fieldType with as value type a RecordValueType
        FieldType fieldType2 = typeManager.createFieldType(typeManager.newFieldType(recordVT1, new QName(ns, "field2"), Scope.NON_VERSIONED));
        // Create a recordType with a field of this field type
        RecordType rt2 = typeManager.recordTypeBuilder()
            .name(new QName(ns, "rt2"))
            .field(fieldType2.getId(), false)
            .create();

        // Make a record to be used as field value, specify the record type here
        Record recordField = repository.recordBuilder().recordType(new QName(ns, "rt1")).field(new QName(ns, "field1"), "abc").build();
        recordField.setRecordType(Scope.VERSIONED, new QName(ns, "vrt"), null); // This record type should be ignored
View Full Code Here

        lilyClient = lilyServerProxy.getClient();
        repository = lilyClient.getRepository(REPO_NAME);
        table = repository.getDefaultTable();

        typeManager = repository.getTypeManager();
        FieldType ft1 = typeManager.createFieldType("STRING", new QName("batchindex-test", "field1"),
                Scope.NON_VERSIONED);
        FieldType ft2 =
                typeManager.createFieldType("LINK", new QName("batchindex-test", "linkField"), Scope.NON_VERSIONED);
        typeManager.recordTypeBuilder()
                .defaultNamespace("batchindex-test")
                .name("rt1")
                .fieldEntry().use(ft1).add()
View Full Code Here

    @Test
    public void testRecordVTNoTypeDefined() throws Exception {
        String ns = "testRecordVTNoTypeDefined";
        // Create a fieldType to be used as a field in a record type to be used as the type for a RecordValueType
        FieldType fieldType1 = typeManager.createFieldType(typeManager.newFieldType(typeManager.getValueType("STRING"), new QName(ns, "field1"), Scope.NON_VERSIONED));
        // Create a record type to be used as the type for a RecordValueType
        RecordType rt1 = typeManager.recordTypeBuilder()
            .name(new QName(ns, "rt1"))
            .field(fieldType1.getId(), false)
            .create();

        // Make a RecordValueType without the record type specified
        ValueType recordVT1 = typeManager.getValueType("RECORD");

        // Create a fieldType with as value type a RecordValueType
        FieldType fieldType2 = typeManager.createFieldType(typeManager.newFieldType(recordVT1, new QName(ns, "field2"), Scope.NON_VERSIONED));

        // Create a recordType with a field of this field type
        RecordType rt2 = typeManager.recordTypeBuilder()
            .name(new QName(ns, "rt2"))
            .field(fieldType2.getId(), false)
            .create();

        // Make a record to be used as field value, don't specify the record type here either
        Record recordField = repository.recordBuilder().field(new QName(ns, "field1"), "abc").build();
View Full Code Here

    @Test
    public void testRecordVTUndefinedField() throws Exception {
        String ns = "testRecordVTUndefinedField";
        // Create a fieldType to be used as a field in a record type to be used as the type for a RecordValueType
        FieldType fieldType1 = typeManager.createFieldType(typeManager.newFieldType(typeManager.getValueType("STRING"), new QName(ns, "field1"), Scope.NON_VERSIONED));
        FieldType fieldType1b = typeManager.createFieldType(typeManager.newFieldType(typeManager.getValueType("STRING"), new QName(ns, "field1b"), Scope.NON_VERSIONED));
        // Create a record type to be used as the type for a RecordValueType
        RecordType rt1 = typeManager.recordTypeBuilder()
            .name(new QName(ns, "rt1"))
            .field(fieldType1.getId(), false)
            .field(fieldType1b.getId(), false)
            .create();

        // Make a RecordValueType without the record type specified
        ValueType recordVT1 = typeManager.getValueType("RECORD");

        // Create a fieldType with as value type a RecordValueType
        FieldType fieldType2 = typeManager.createFieldType(typeManager.newFieldType(recordVT1, new QName(ns, "field2"), Scope.NON_VERSIONED));
        // Create a recordType with a field of this field type
        RecordType rt2 = typeManager.recordTypeBuilder()
            .name(new QName(ns, "rt2"))
            .field(fieldType2.getId(), false)
            .create();

        // Make a record to be used as field value, specify the record type here
        // Only fill in field1, not field1b
        Record recordField = repository.recordBuilder().recordType(new QName(ns, "rt1")).field(new QName(ns, "field1"), "abc").build();
View Full Code Here

    @Test
    public void testRecordVTUnallowedField() throws Exception {
        String ns = "testRecordVTUnallowedField";
        // Create a fieldType to be used as a field in a record type to be used as the type for a RecordValueType
        FieldType fieldType1 = typeManager.createFieldType(typeManager.newFieldType(typeManager.getValueType("STRING"), new QName(ns, "field1"), Scope.NON_VERSIONED));
        FieldType fieldType1b = typeManager.createFieldType(typeManager.newFieldType(typeManager.getValueType("STRING"), new QName(ns, "field1b"), Scope.NON_VERSIONED));
        // Create a record type to be used as the type for a RecordValueType
        // Do not add fieldType1b to the record type
        RecordType rt1 = typeManager.recordTypeBuilder()
            .name(new QName(ns, "rt1"))
            .field(fieldType1.getId(), false)
            .create();

        // Make a RecordValueType without the record type specified
        ValueType recordVT1 = typeManager.getValueType("RECORD");

        // Create a fieldType with as value type a RecordValueType
        FieldType fieldType2 = typeManager.createFieldType(typeManager.newFieldType(recordVT1, new QName(ns, "field2"), Scope.NON_VERSIONED));
        // Create a recordType with a field of this field type
        RecordType rt2 = typeManager.recordTypeBuilder()
            .name(new QName(ns, "rt2"))
            .field(fieldType2.getId(), false)
            .create();

        // Make a record to be used as field value, specify the record type here
        Record recordField = repository.recordBuilder()
            .recordType(new QName(ns, "rt1"))
View Full Code Here

    @Test
    public void testRecordVTReadWrite() throws Exception {
        String ns = "testRecordVTWrite";
     // Create a fieldType to be used as a field in a record type to be used as the type for a RecordValueType
        FieldType fieldType1 = typeManager.createFieldType(typeManager.newFieldType(typeManager.getValueType("STRING"), new QName(ns, "field1"), Scope.NON_VERSIONED));
        // Create a record type to be used as the type for a RecordValueType
        RecordType rt1 = typeManager.recordTypeBuilder().name(new QName(ns, "rt1")).field(fieldType1.getId(), false).create();

        // Make a RecordValueType without the record type specified
        ValueType recordVT = typeManager.getValueType("RECORD");

View Full Code Here

TOP

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

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.