Package org.lilyproject.repository.api

Examples of org.lilyproject.repository.api.TypeManager


        repositoryModel.create("repo2");
        assertTrue(repositoryModel.waitUntilRepositoryInState("repo2", RepositoryLifecycleState.ACTIVE, 60000L));
        repositoryModel.close();

        // 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");
        IdentityHashMap<Object, Object> chains = new IdentityHashMap<Object, Object>();
View Full Code Here


            Long rtVersion = readNullOrVLong(input);
            record.setRecordType(scope, recordType, rtVersion);
        }

        // Read fields array
        TypeManager typeManager = repository.getTypeManager();
        int size = input.readVInt();
        for (int i = 0; i < size; i++) {
            QName name = readQName(input);
            String valueTypeName = input.readUTF();
            ValueType valueType = typeManager.getValueType(valueTypeName);
            Object value = valueType.read(input);
            record.setField(name, value);
        }

        // Read fields to delete
View Full Code Here

    }

    protected static class RecordKeyValueFormatter implements ValueFormatter {
        @Override
        public String format(Object record, ValueType valueType, FormatContext formatCtx) throws InterruptedException {
            TypeManager typeManager = formatCtx.repository.getTypeManager();

            StringWriter writer = new StringWriter();
            try {
                JsonGenerator gen = JsonFormat.JSON_FACTORY.createJsonGenerator(writer);

                gen.writeStartObject();
                for (Map.Entry<QName, Object> field : ((Record) record).getFields().entrySet()) {
                    ValueType fieldValueType;
                    try {
                        fieldValueType = typeManager.getFieldTypeByName(field.getKey()).getValueType();
                    } catch (RepositoryException e) {
                        continue;
                    }

                    String result = formatCtx.format(field.getValue(), fieldValueType, formatCtx);
View Full Code Here

                .getLilyServerTestingUtility().getRuntime().getJavaServiceManager()
                .getService(org.lilyproject.repository.api.RepositoryManager.class);

        // Create a record type
        LRepository repository = repositoryManager.getDefaultRepository();
        TypeManager typeManager = repository.getTypeManager();
        typeManager.recordTypeBuilder()
                .defaultNamespace("authztest")
                .name("Type1")
                .fieldEntry().defineField().name("field1").create().add()
                .fieldEntry().defineField().name("field2").create().add()
                .create();
View Full Code Here

        repositoryModel.create("company1");
        repositoryModel.create("company2");
        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");
View Full Code Here

        assertEquals("1/foo/bar", result.get(1));
    }

    @Test
    public void testMultiValue() throws Exception {
        TypeManager typeManager = mock(TypeManager.class);
        when(typeManager.getValueType("STRING")).thenReturn(new StringValueType());

        ValueType valueType = new ListValueType(typeManager, "STRING");
        FieldType fieldType = mock(FieldType.class);
        when(fieldType.getValueType()).thenReturn(valueType);
View Full Code Here

        Repository repository = client.getRepository();

        String NS = "org.lilyproject.client.test";

        // Create a blob field type and record type
        TypeManager typeManager = repository.getTypeManager();
        ValueType blobType = typeManager.getValueType("BLOB");
        FieldType blobFieldType = typeManager.newFieldType(blobType, new QName(NS, "data"), Scope.VERSIONED);
        blobFieldType = typeManager.createFieldType(blobFieldType);

        RecordType recordType = typeManager.newRecordType(new QName(NS, "file"));
        recordType.addFieldTypeEntry(blobFieldType.getId(), true);
        recordType = typeManager.createRecordType(recordType);


        // Upload a blob that, based upon the current default config, should end up in HBase
        //  (> 5000 bytes and < 200000 bytes)
        byte[] data = makeBlobData(10000);
View Full Code Here

        IdGenerator idGenerator = repository.getIdGenerator();

        String NS = "org.lilyproject.client.test";

        // Create a field type and record type
        TypeManager typeManager = repository.getTypeManager();
        FieldType fieldType = typeManager.newFieldType("STRING", new QName(NS, "scanfield"), Scope.VERSIONED);
        fieldType = typeManager.createFieldType(fieldType);

        RecordType recordType = typeManager.newRecordType(new QName(NS, "scanrt"));
        recordType.addFieldTypeEntry(fieldType.getId(), true);
        recordType = typeManager.createRecordType(recordType);

        // Create some records
        for (int i = 0; i < 10; i++) {
            Record record = repository.newRecord();
            record.setId(repository.getIdGenerator().newRecordId("A" + i));
View Full Code Here

        //
        // Create some content in the default table of the default repository
        //
        LRepository repository = repoMgr.getDefaultRepository();
        TypeManager typeManager = repository.getTypeManager();
        IdGenerator idGenerator = repository.getIdGenerator();
        LTable table = repository.getDefaultTable();

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

        RecordType rt1 = typeManager.recordTypeBuilder()
                .defaultNamespace("test")
                .name("rt1")
                .fieldEntry().use(ft1).add()
                .create();
View Full Code Here

    }

    @Override
    public IdRecord readWithIds(RecordId recordId, Long aLong, List<SchemaId> schemaIds) throws RepositoryException, InterruptedException {
        Record record = getRecord(recordId);
        TypeManager typeManager = this.getTypeManager();

        Map<SchemaId, QName> map = Maps.newHashMap();
        for (QName qname : record.getFields().keySet()) {
            map.put(typeManager.getFieldTypeByName(qname).getId(), qname);           
        }

        Map<Scope,SchemaId> recordTypeIds = Maps.newHashMap();
        for (Scope scope : Scope.values()) {
            RecordType recordType = typeManager.getRecordTypeByName(record.getRecordTypeName(scope), record.getVersion());
            if (recordType != null) {
                recordTypeIds.put(scope, recordType.getId());
            }
        }
        IdRecord idRecord = new IdRecordImpl(record, map, recordTypeIds);
View Full Code Here

TOP

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

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.