Package org.lilyproject.repository.api

Examples of org.lilyproject.repository.api.FieldType


        assertTrue(recordTypes.contains(recordType));
    }

    @Test
    public void testGetFieldTypes() throws Exception {
        FieldType fieldType = typeManager.createFieldType(typeManager.newFieldType(typeManager.getValueType("STRING"), new QName("NS", "getFieldTypes"), Scope.NON_VERSIONED));
        Collection<FieldType> fieldTypes = typeManager.getFieldTypes();
        assertTrue(fieldTypes.contains(fieldType));
    }
View Full Code Here


    @Test
    public void testCreateOrUpdate() throws Exception {
        String NS = "testCreateOrUpdateRecordType";

        FieldType field1 = typeManager.createFieldType("STRING", new QName(NS, "field1"), Scope.NON_VERSIONED);
        FieldType field2 = typeManager.createFieldType("STRING", new QName(NS, "field2"), Scope.NON_VERSIONED);
        FieldType field3 = typeManager.createFieldType("STRING", new QName(NS, "field3"), Scope.NON_VERSIONED);

        RecordType recordType = typeManager.newRecordType(new QName(NS, "type1"));
        recordType.addFieldTypeEntry(field1.getId(), false);
        recordType.addFieldTypeEntry(field2.getId(), false);

        recordType = typeManager.createOrUpdateRecordType(recordType);
        assertNotNull(recordType.getId());

        // Without changing anything, do an update
        RecordType updatedRecordType = typeManager.createOrUpdateRecordType(recordType);
        assertEquals(recordType, updatedRecordType);

        // Remove the id from the record type and do a change
        recordType.setId(null);
        recordType.addFieldTypeEntry(field3.getId(), false);
        typeManager.createOrUpdateRecordType(recordType);
        recordType = typeManager.getRecordTypeByName(new QName(NS, "type1"), null);
        assertEquals(3, recordType.getFieldTypeEntries().size());
    }
View Full Code Here

        String NS = "testRecordTypeBuilderFieldsAndSupertypes";

        //
        // Create some field types
        //
        FieldType field1 = typeManager.createFieldType("STRING", new QName(NS, "field1"), VERSIONED);
        FieldType field2 = typeManager.createFieldType("STRING", new QName(NS, "field2"), VERSIONED);
        FieldType field3 = typeManager.createFieldType("STRING", new QName(NS, "field3"), VERSIONED);
        FieldType field4 = typeManager.createFieldType("STRING", new QName(NS, "field4"), VERSIONED);
        FieldType field5 = typeManager.createFieldType("STRING", new QName(NS, "field5"), VERSIONED);

        //
        // Create some supertypes
        //
        FieldType field21 = typeManager.createFieldType("STRING", new QName(NS, "field21"), VERSIONED);
        FieldType field22 = typeManager.createFieldType("STRING", new QName(NS, "field22"), VERSIONED);
        FieldType field23 = typeManager.createFieldType("STRING", new QName(NS, "field23"), VERSIONED);
        FieldType field24 = typeManager.createFieldType("STRING", new QName(NS, "field24"), VERSIONED);
        FieldType field25 = typeManager.createFieldType("STRING", new QName(NS, "field25"), VERSIONED);
        FieldType field26 = typeManager.createFieldType("STRING", new QName(NS, "field26"), VERSIONED);
        FieldType field27 = typeManager.createFieldType("STRING", new QName(NS, "field27"), VERSIONED);
        FieldType field28 = typeManager.createFieldType("STRING", new QName(NS, "field28"), VERSIONED);
        FieldType field29 = typeManager.createFieldType("STRING", new QName(NS, "field29"), VERSIONED);

        RecordType supertype1 = typeManager.recordTypeBuilder().name(NS, "supertype1").fieldEntry().use(field21).add().create();
        RecordType supertype2 = typeManager.recordTypeBuilder().name(NS, "supertype2").fieldEntry().use(field22).add().create();
        RecordType supertype3 = typeManager.recordTypeBuilder().name(NS, "supertype3").fieldEntry().use(field23).add().create();
        RecordType supertype4 = typeManager.recordTypeBuilder().name(NS, "supertype4").fieldEntry().use(field24).add().create();
        RecordType supertype5 = typeManager.recordTypeBuilder().name(NS, "supertype5").fieldEntry().use(field25).add().create();
        RecordType supertype6 = typeManager.recordTypeBuilder().name(NS, "supertype6").fieldEntry().use(field26).add().create();
        RecordType supertype7 = typeManager.recordTypeBuilder().name(NS, "supertype7").fieldEntry().use(field27).add().create();
        // give supertype7 two more versions
        supertype7.addFieldTypeEntry(field28.getId(), false);
        supertype7 = typeManager.updateRecordType(supertype7);
        supertype7.addFieldTypeEntry(field29.getId(), false);
        supertype7 = typeManager.updateRecordType(supertype7);

        RecordType recordType = typeManager
                .recordTypeBuilder()
                .defaultNamespace(NS)
                .name("recordType1")

                /* Adding previously defined fields */
                /* By ID */
                .fieldEntry().id(field1.getId()).add()
                /* By object + test mandatory flag */
                .fieldEntry().use(field2).mandatory().add()
                /* By non-qualified name */
                .fieldEntry().name("field3").add()
                /* By qualified name */
                .fieldEntry().name(new QName(NS, "field4")).add()
                /* By indirect qualified name*/
                .fieldEntry().name(NS, "field5").add()

                /* Adding newly created fields */
                /* Using default default scope */
                .fieldEntry().defineField().name("field10").type("LIST<STRING>").create().add()
                /* Using default type (STRING) */
                .fieldEntry().defineField().name("field11").create().add()
                /* Using QName */
                .fieldEntry().defineField().name(new QName(NS, "field12")).create().add()
                /* Using explicit scope */
                .fieldEntry().defineField().name("field13").type("LONG").scope(VERSIONED).create().add()
                /* Using different default scope */
                .defaultScope(Scope.VERSIONED)
                .fieldEntry().defineField().name("field14").create().add()
                /* Using indirect qualified name*/
                .fieldEntry().defineField().name(NS, "field15").create().add()

                /* Adding supertypes */
                .supertype().id(supertype1.getId()).add()
                .supertype().name("supertype2").add()
                .supertype().name(new QName(NS, "supertype3")).add()
                .supertype().name(NS, "supertype4").add()
                .supertype().use(supertype5).add()
                .supertype().name(NS, "supertype7").version(2L).add()

                .create();

        //
        // Global checks
        //
        assertEquals(new QName(NS, "recordType1"), recordType.getName());

        //
        // Verify fields
        //
        assertEquals(11, recordType.getFieldTypeEntries().size());

        assertFalse(recordType.getFieldTypeEntry(field1.getId()).isMandatory());
        assertTrue(recordType.getFieldTypeEntry(field2.getId()).isMandatory());
        assertFalse(recordType.getFieldTypeEntry(field3.getId()).isMandatory());

        // Verify the inline created fields
        FieldType field10 = typeManager.getFieldTypeByName(new QName(NS, "field10"));
        assertEquals("LIST<STRING>", field10.getValueType().getName());
        assertEquals(Scope.NON_VERSIONED, field10.getScope());
        assertNotNull(recordType.getFieldTypeEntry(field10.getId()));

        FieldType field11 = typeManager.getFieldTypeByName(new QName(NS, "field11"));
        assertEquals("STRING", field11.getValueType().getName());
        assertEquals(Scope.NON_VERSIONED, field11.getScope());
        assertNotNull(recordType.getFieldTypeEntry(field11.getId()));

        FieldType field13 = typeManager.getFieldTypeByName(new QName(NS, "field13"));
        assertEquals(Scope.VERSIONED, field13.getScope());

        FieldType field14 = typeManager.getFieldTypeByName(new QName(NS, "field14"));
        assertEquals(Scope.VERSIONED, field14.getScope());

        //
        // Verify supertypes
        //
        Map<SchemaId, Long> supertypes = recordType.getSupertypes();
View Full Code Here

        ValueType valueType = new StringValueType();
        typeManager.getValueType("STRING");
        expectLastCall().andReturn(valueType);
        QName name = new QName("aNamespace", "aName");
        SchemaId fieldTypeId = new SchemaIdImpl(UUID.randomUUID());
        FieldType fieldType = new FieldTypeImpl(fieldTypeId, valueType, name, Scope.NON_VERSIONED);
        typeManager.newFieldType(fieldTypeId, valueType, name, Scope.NON_VERSIONED);
        expectLastCall().andReturn(fieldType);

        control.replay();
        converter = new AvroConverter();
View Full Code Here

    public void testFieldTypeWithoutId() throws Exception {
        ValueType valueType = new StringValueType();
        typeManager.getValueType("LIST<STRING>");
        expectLastCall().andReturn(valueType);
        QName name = new QName("aNamespace", "aName");
        FieldType fieldType = new FieldTypeImpl(null, valueType, name, Scope.NON_VERSIONED);
        typeManager.newFieldType(valueType, name, Scope.NON_VERSIONED);
        expectLastCall().andReturn(fieldType);

        control.replay();
        converter = new AvroConverter();
View Full Code Here

    }

    @Test
    public void testRecord() throws Exception {
        converter = new AvroConverter();
        FieldType fieldType = control.createMock(FieldType.class);
        FieldTypes fieldTypesSnapshot = control.createMock(FieldTypes.class);
        ValueType valueType = new StringValueType();
        IdGenerator idGenerator = new IdGeneratorImpl();

        recordFactory.newRecord();
        expectLastCall().andReturn(new RecordImpl()).anyTimes();
        repository.getIdGenerator();
        expectLastCall().andReturn(idGenerator).anyTimes();
        typeManager.getFieldTypesSnapshot();
        expectLastCall().andReturn(fieldTypesSnapshot).anyTimes();
        fieldTypesSnapshot.getFieldType(isA(QName.class));
        expectLastCall().andReturn(fieldType).anyTimes();
        fieldType.getValueType();
        expectLastCall().andReturn(valueType).anyTimes();
        typeManager.getValueType("STRING");
        expectLastCall().andReturn(valueType).anyTimes();
        control.replay();
View Full Code Here

        Repository repository = client.getRepository();

        TypeManager typeMgr = repository.getTypeManager();

        QName fieldName = new QName("ns", "f1");
        FieldType fieldType = typeMgr.newFieldType(typeMgr.getValueType("STRING"), fieldName, Scope.NON_VERSIONED);
        fieldType = typeMgr.createFieldType(fieldType);

        QName typeName = new QName("ns", "rt1");
        RecordType recordType = typeMgr.newRecordType(typeName);
        recordType.addFieldTypeEntry(fieldType.getId(), false);
        recordType = typeMgr.createRecordType(recordType);

        Record record = repository.newRecord();
        record.setRecordType(typeName);
        record.setField(fieldName, "foo");
View Full Code Here

        //
        Repository repository = client.getRepository();
        TypeManager typeManager = repository.getTypeManager();
        IdGenerator idGenerator = repository.getIdGenerator();

        FieldType ft1 = typeManager.createFieldType("STRING", new QName("test", "field1"), Scope.NON_VERSIONED);
        FieldType ft2 = typeManager.createFieldType("LINK", new QName("test", "field2"), Scope.NON_VERSIONED);

        RecordType rt1 = typeManager.recordTypeBuilder()
                .defaultNamespace("test")
                .name("rt1")
                .fieldEntry().use(ft1).add()
                .fieldEntry().use(ft2).add()
                .create();

        for (int i = 0; i < 300; i++) {
            repository.recordBuilder()
                    .recordType(rt1.getName())
                    .field(ft1.getName(), "foo bar bar")
                    .field(ft2.getName(), new Link(idGenerator.newRecordId()))
                    .create();
        }

        Assert.assertTrue("Processing messages took too long", lilyProxy.waitSepEventsProcessed(60000L));
View Full Code Here

        // Make a schema
        TypeManager typeMgr = client.getDefaultRepository().getTypeManager();

        QName field1 = new QName("ns", "f1");
        FieldType fieldType1 = typeMgr.newFieldType(typeMgr.getValueType("STRING"), field1, Scope.NON_VERSIONED);
        fieldType1 = typeMgr.createFieldType(fieldType1);

        QName field2 = new QName("ns", "f2");
        FieldType fieldType2 = typeMgr.newFieldType(typeMgr.getValueType("STRING"), field2, Scope.NON_VERSIONED);
        fieldType2 = typeMgr.createFieldType(fieldType2);

        QName typeName = new QName("ns", "rt1");
        RecordType recordType = typeMgr.newRecordType(typeName);
        recordType.addFieldTypeEntry(fieldType1.getId(), false);
        recordType.addFieldTypeEntry(fieldType2.getId(), false);
        recordType = typeMgr.createRecordType(recordType);

        DecoratingRepositoryManager repositoryMgr = (DecoratingRepositoryManager)lilyProxy.getLilyServerProxy()
                .getLilyServerTestingUtility().getRuntime().getModuleById("repository")
                .getApplicationContext().getBean("repositoryManager");
View Full Code Here

    }

    @Override
    public InputStream getInputStream(Record record, QName fieldName, int... indexes)
            throws RepositoryException, InterruptedException {
        FieldType fieldType = typeManager.getFieldTypeByName(fieldName);
        return blobManager.getBlobAccess(record, fieldName, fieldType, indexes).getInputStream();
    }
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.