Package org.lilyproject.repository.api

Examples of org.lilyproject.repository.api.RecordType


        assertTrue(repositoryModel.waitUntilRepositoryInState("company1", RepositoryDefinition.RepositoryLifecycleState.ACTIVE, 60000L));
        assertTrue(repositoryModel.waitUntilRepositoryInState("company2", RepositoryDefinition.RepositoryLifecycleState.ACTIVE, 60000L));

        TypeManager typeMgr = repositoryManager.getDefaultRepository().getTypeManager();
        FieldType fieldType1 = typeMgr.createFieldType("STRING", new QName("test", "field1"), Scope.NON_VERSIONED);
        RecordType recordType1 = typeMgr.recordTypeBuilder()
                .name(new QName("test", "rt1"))
                .field(fieldType1.getId(), false)
                .create();

        List<String> repositories = Lists.newArrayList("company1", "company2", "default");

        for (String repoName : repositories) {
            LRepository repo = repositoryManager.getRepository(repoName);
            repo.getTableManager().createTable("mytable");
            LTable table = repo.getTable("mytable");
            table.recordBuilder()
                    .id("id1")
                    .recordType(recordType1.getName())
                    .field(fieldType1.getName(), repoName + "-value1")
                    .create();
        }

        for (String repoName : repositories) {
View Full Code Here


    @Test
    public void testRecordTypeSupertypes() throws Exception {
        QName name = new QName("aNamespace", "aName");
        SchemaId recordTypeId = new SchemaIdImpl(UUID.randomUUID());
        RecordType recordType = new RecordTypeImpl(recordTypeId, name);
        typeManager.newRecordType(recordTypeId, name);
        expectLastCall().andReturn(recordType);

        control.replay();
        converter = new AvroConverter();
        SchemaId supertypeId1 = new SchemaIdImpl(UUID.randomUUID());
        recordType.addSupertype(supertypeId1, 1L);
        SchemaId supertypeId2 = new SchemaIdImpl(UUID.randomUUID());
        recordType.addSupertype(supertypeId2, 2L);
        AvroRecordType avroRecordType = new AvroRecordType();
        AvroSchemaId avroRecordTypeId = new AvroSchemaId();
        avroRecordTypeId.idBytes = ByteBuffer.wrap(recordTypeId.getBytes());
        avroRecordType.id = avroRecordTypeId;
        AvroQName avroQName = new AvroQName();
View Full Code Here

    }

    @Test
    public void testSupertype() throws Exception {
        QName supertypeName = new QName("supertypeNS", "testSupertype");
        RecordType supertypeRt = typeManager.newRecordType(supertypeName);
        supertypeRt.addFieldTypeEntry(typeManager.newFieldTypeEntry(fieldType1.getId(), false));
        supertypeRt.addFieldTypeEntry(typeManager.newFieldTypeEntry(fieldType2.getId(), false));
        supertypeRt.addFieldTypeEntry(typeManager.newFieldTypeEntry(fieldType3.getId(), false));
        supertypeRt = typeManager.createRecordType(supertypeRt);

        QName recordName = new QName("recordNS", "testSupertype");
        RecordType recordType = typeManager.newRecordType(recordName);
        recordType.addSupertype(supertypeRt.getId(), supertypeRt.getVersion());
        recordType = typeManager.createRecordType(recordType);
        assertEquals(Long.valueOf(1), recordType.getVersion());
        assertEquals(recordType, typeManager.getRecordTypeById(recordType.getId(), null));
    }
View Full Code Here

    }

    @Test
    public void testSupertypeLatestVersion() throws Exception {
        QName supertypeName = new QName("supertypeNS", "testSupertypeLatestVersion");
        RecordType supertypeType = typeManager.newRecordType(supertypeName);
        supertypeType.addFieldTypeEntry(typeManager.newFieldTypeEntry(fieldType1.getId(), false));
        supertypeType = typeManager.createRecordType(supertypeType);

        supertypeType.addFieldTypeEntry(typeManager.newFieldTypeEntry(fieldType2.getId(), false));
        supertypeType.addFieldTypeEntry(typeManager.newFieldTypeEntry(fieldType3.getId(), false));
        supertypeType = typeManager.updateRecordType(supertypeType);

        QName recordName = new QName("recordNS", "testSupertypeLatestVersion");
        RecordType recordType = typeManager.newRecordType(recordName);
        recordType.addSupertype(supertypeType.getId());
        recordType = typeManager.createRecordType(recordType);
        assertEquals(Long.valueOf(1), recordType.getVersion());

        recordType.addSupertype(supertypeType.getId(), 2L); // Assert latest version of the supertype RecordType got filled in
        assertEquals(recordType, typeManager.getRecordTypeById(recordType.getId(), null));
    }
View Full Code Here

    }

    @Test
    public void testSupertypeUpdate() throws Exception {
        QName supertypeName = new QName("supertypeNS", "testSupertypeUpdate");
        RecordType supertypeRt1 = typeManager.newRecordType(supertypeName);
        supertypeRt1.addFieldTypeEntry(typeManager.newFieldTypeEntry(fieldType1.getId(), false));
        supertypeRt1.addFieldTypeEntry(typeManager.newFieldTypeEntry(fieldType2.getId(), false));
        supertypeRt1.addFieldTypeEntry(typeManager.newFieldTypeEntry(fieldType3.getId(), false));
        supertypeRt1 = typeManager.createRecordType(supertypeRt1);

        QName supertypeName2 = new QName("supertypeNS", "testSupertypeUpdate2");
        RecordType supertypeRt2 = typeManager.newRecordType(supertypeName2);
        supertypeRt2.addFieldTypeEntry(typeManager.newFieldTypeEntry(fieldType1.getId(), false));
        supertypeRt2.addFieldTypeEntry(typeManager.newFieldTypeEntry(fieldType2.getId(), false));
        supertypeRt2.addFieldTypeEntry(typeManager.newFieldTypeEntry(fieldType3.getId(), false));
        supertypeRt2 = typeManager.createRecordType(supertypeRt2);

        QName recordName = new QName("recordNS", "testSupertypeUpdate");
        RecordType recordType = typeManager.newRecordType(recordName);
        recordType.addSupertype(supertypeRt1.getId(), supertypeRt1.getVersion());
        recordType = typeManager.createRecordType(recordType);

        recordType.addSupertype(supertypeRt2.getId(), supertypeRt2.getVersion());
        recordType = typeManager.updateRecordType(recordType);
        assertEquals(Long.valueOf(2), recordType.getVersion());
        assertEquals(recordType, typeManager.getRecordTypeById(recordType.getId(), null));
    }
View Full Code Here

    }

    @Test
    public void testSupertypeRemove() throws Exception {
        QName supertypeName = new QName("supertypeNS", "testSupertypeRemove");
        RecordType supertypeRt1 = typeManager.newRecordType(supertypeName);
        supertypeRt1.addFieldTypeEntry(typeManager.newFieldTypeEntry(fieldType1.getId(), false));
        supertypeRt1.addFieldTypeEntry(typeManager.newFieldTypeEntry(fieldType2.getId(), false));
        supertypeRt1.addFieldTypeEntry(typeManager.newFieldTypeEntry(fieldType3.getId(), false));
        supertypeRt1 = typeManager.createRecordType(supertypeRt1);

        QName supertypeName2 = new QName("supertypeNS", "testSupertypeRemove2");
        RecordType supertypeRt2 = typeManager.newRecordType(supertypeName2);
        supertypeRt2.addFieldTypeEntry(typeManager.newFieldTypeEntry(fieldType1.getId(), false));
        supertypeRt2.addFieldTypeEntry(typeManager.newFieldTypeEntry(fieldType2.getId(), false));
        supertypeRt2.addFieldTypeEntry(typeManager.newFieldTypeEntry(fieldType3.getId(), false));
        supertypeRt2 = typeManager.createRecordType(supertypeRt2);

        QName recordTypeName = new QName("recordNS", "testSupertypeRemove");
        RecordType recordType = typeManager.newRecordType(recordTypeName);
        recordType.addSupertype(supertypeRt1.getId(), supertypeRt1.getVersion());
        recordType = typeManager.createRecordType(recordType);

        recordType.addSupertype(supertypeRt2.getId(), supertypeRt2.getVersion());
        recordType.removeSupertype(supertypeRt1.getId());
        recordType = typeManager.updateRecordType(recordType);
        assertEquals(Long.valueOf(2), recordType.getVersion());
        RecordType readRecordType = typeManager.getRecordTypeById(recordType.getId(), null);
        Map<SchemaId, Long> supertypes = readRecordType.getSupertypes();
        assertEquals(1, supertypes.size());
        assertEquals(Long.valueOf(1), supertypes.get(supertypeRt2.getId()));
    }
View Full Code Here

        assertEquals(Long.valueOf(1), supertypes.get(supertypeRt2.getId()));
    }

    @Test
    public void testGetRecordTypes() throws Exception {
        RecordType recordType = typeManager.createRecordType(typeManager.newRecordType(new QName("NS", "getRecordTypes")));
        Collection<RecordType> recordTypes = typeManager.getRecordTypes();
        assertTrue(recordTypes.contains(recordType));
    }
View Full Code Here

    }

    @Test
    public void testUpdateName() throws Exception {
        QName name = new QName(namespace1, "testUpdateName");
        RecordType recordType = typeManager.newRecordType(name);
        recordType = typeManager.createRecordType(recordType);
        assertEquals(name, recordType.getName());

        QName name2 = new QName(namespace1, "testUpdateName2");
        recordType.setName(name2);
        recordType = typeManager.updateRecordType(recordType);
        recordType = typeManager.getRecordTypeById(recordType.getId(), null);
        assertEquals(name2, recordType.getName());
    }
View Full Code Here

    @Test
    public void testUpdateNameToExistingNameFails() throws Exception {
        QName name = new QName(namespace1, "testUpdateNameToExistingNameFails");
        QName name2 = new QName(namespace1, "testUpdateNameToExistingNameFails2");

        RecordType recordType = typeManager.newRecordType(name);
        recordType = typeManager.createRecordType(recordType);
        assertEquals(name, recordType.getName());

        RecordType recordType2 = typeManager.newRecordType(name2);
        recordType2 = typeManager.createRecordType(recordType2);

        recordType.setName(name2);
        try {
            System.out.println("Expecting TypeException");
View Full Code Here

        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);
View Full Code Here

TOP

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

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.